I have a standalone colorbar that I would like to make vertical :
cb_colors = ["#41fdfe", "blue", "brown", "grey"]
num_colors = len(cb_colors)
cmap_ = matplotlib.colors.ListedColormap(cb_colors)
fig = plt.figure()
ax = fig.add_axes([0.05, 0.80, 0.9, 0.1])
cb = matplotlib.colorbar.ColorbarBase(ax, orientation='horizontal',
cmap=cmap_, norm=plt.Normalize( - 0.5 , num_colors - 0.5 ))
cb.set_ticks(range(num_colors))
cb.ax.set_xticklabels(["A", "B", "C", "D"])
I've tried oriental = 'vertical'
in matplotlib.colorbar
but it doesnt seem to work. I find this as a result but I would like this :
Thank you !
CodePudding user response:
Three things you need to do: