Exemple de comment tourner les labels d'une colorbar avec matplotlib:

import numpy as npimport matplotlib.pyplot as pltimport matplotlib.cm as cmimport matplotlib as mplx = np.linspace(-3.0, 3.0, 100)y = np.linspace(-3.0, 3.0, 100)X, Y = np.meshgrid(x, y)Z = np.sqrt(X**2 + Y**2)max_value = Z.max()min_value = Z.min()plt.figure()cmap = cm.jetbounds = [i for i in np.linspace(min_value,max_value,5)]norm = mpl.colors.BoundaryNorm(bounds, cmap.N)img = plt.imshow(Z, norm=norm)cbar_ticks = [ bounds[i] + (bounds[i+1]-bounds[i]) / 2.0 for i in range(4)]cbar_labels = ['Area 1','Area 2','Area 3','Area 4']cbar = plt.colorbar(img, norm=norm, boundaries=bounds, ticks=cbar_ticks)cbar.ax.set_yticklabels(cbar_labels, fontsize=10, rotation=90)plt.title('Rotation of colorbar tick labels in matplotlib')plt.savefig("rotation_of_colorbar_tick_labels_in_matplotlib.png", bbox_inches='tight')plt.show()
Références
| Liens | Site |
|---|---|
| Rotation of colorbar tick labels in matplotlib | stackoverflow |
| matplotlib: colorbars and its text labels | stackoverflow |
| Top label for matplotlib colorbars | stackoverflow |
