Hi, I did solve my own question. For posterity, and perhaps for a more elegant solution, I post my solution here.
On Tue, 2010-10-26 at 10:56 +0200, Maarten Sneep wrote: > I have an image with cloud pressures, 1000 at the surface, 200 at the > top of the atmosphere. I'd like to reverse the axis, i.e. 1000 at the > bottom of the scale, 200 at the top. How should I approach this? Instead of using a figure.colorbar() call, I instantiate ColorbarBase directly. I needed an axes object anyway to use a single colorbar fro a two-subplot figure. The ColorbarBase gets the reversed colormap compared to the image. fig = plt.figure() norm=Normalize(vmin=200.0, vmax=1000.0, clip=False) cmap = cm.jet cmap.set_bad(color=(0.75,0.75, 0.75)) cmap.set_over(color=(1.0, 1.0, 1.0)) cmap.set_under(color=(0.5, 0.5, 0.5)) cmap_bar = cm.jet_r # note that under and over are reversed. cmap_bar.set_bad(color=(0.75,0.75, 0.75)) cmap_bar.set_under(color=(1.0, 1.0, 1.0)) cmap_bar.set_over(color=(0.5, 0.5, 0.5)) # make subplots ax1 = fig.add_subplot(211) ax1.imshow(cp1, origin='lower', cmap=cmap, interpolation='nearest', aspect='auto', norm=norm) ax2 = fig.add_subplot(212) ax2.imshow(cp2, origin='lower', cmap=cmap, interpolation='nearest', aspect='auto', norm=norm) # make room for colorbar plt.subplots_adjust(left=0.07, hspace=0.25, right=0.825) cbar_ax = plt.axes([0.875, 0.1, 0.025, 0.8]) tickvals = [200, 400, 600, 800, 1000] cbar = ColorbarBase(cbar_ax, cmap=cmap_bar, ticks=tickvals, extend='both', norm=norm) # I use latex formatting, original is more interesting. labels = ['%d' % v for v in tickvals] cbar.ax.set_yticklabels(lblslabels[::-1]) Dirty: yes, and it only works because of the equidistant labels. A more elegant solution is appreciated. > Related: I have set colors for under- and over-values. I'd like to > display a small patch of these colors at either end of the scale. The > bad values are clear enough. extend='both' keyword to the ColorbarBase() call, or the colorbar() call. Maarten ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users