Skip to content
Advertisement

Change the rotation of a standalone colorbar

I have a standalone colorbar that I would like to make vertical :

JavaScript

I’ve tried oriental = 'vertical' in matplotlib.colorbar but it doesnt seem to work. I find this as a result enter image description here but I would like this :

enter image description here

Thank you !

Advertisement

Answer

Three things you need to do:

  1. change the dimension, the order in add_axes is [left, bottom, width, height] so we need to switch the last two

  2. provide the correct orientation orientation='vertical'

  3. set y instead of x ticks: cb.ax.set_yticklabels(["A", "B", "C", "D"])

Code:

JavaScript

Result:

enter image description here

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement