|
From: Chao Y. <cha...@gm...> - 2012-11-10 15:07:42
|
Dear all, Is there a way to reverse the colorbar label, the default is small value at the bottom and big value at the top, yet I would like the big value at the bottom and small value at the top. all code in pylab mode. import numpy as np import matplotlib as mat a = np.arange(100).reshape(10,10) contourf(a,levels=np.arange(0,101,10)) colorbar() in the above figure, colorbar label shows 0 at the bottom and 100 at the top. Yet I want the 0 at the top and the 100 at the bottom, with the same sequence of colors in the colorbar. One way is to reverse the cmap, and then reverse the colorbar labels at the same time: a = np.arange(100).reshape(10,10) contourf(a,levels=np.arange(0,101,10),cmap=mat.cm.jet_r) cbar = colorbar() cbar.set_ticks(np.arange(0,101,10)) cbar.set_ticklabels(np.arange(100,-1,-10)) But the problem is, sometimes I used the customized colormap, and to increase the contrast, I do linear transformation for the data before I plot them. The the data that are really used for plotting are not the same. But in the colorbar label, I used the values before transformation. Is this complicated case, reverse the customized colormap could not solve the problem (unlike in the simple example above.) Does anyone have the same experience? Thanks et cheers, Chao -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************ |