OK, upon a more careful review of the code, I made a simple(-minded) error. Specifying vmin and vmax do work (as everyone already knew).

Thanks to Jae-Joon and Eric for their quick replies. and valuable suggestions.

-- jv

Jim Vickroy wrote:
I want to generate a 2-d figure with a (fixed) color scale that does not vary with the range of the data being plotted.

How do I do this? Attempts to specify vimin and vmax appear to be ignored.

The following example:

#<code>
import numpy
data = numpy.zeros(shape=(240,240),dtype=int)
data[  0: 80] = -1
data[ 80:160] =  0
data[160:]    =  1

import matplotlib.pyplot as plot
figure = plot.figure()
ax     = figure.add_subplot(111)
cax    = ax.imshow(data, interpolation='bilinear')
ax.set_title('test data with fixed colorbar')
colorbar = figure.colorbar(cax, ticks=[-1, 0, 1])
colorbar.ax.set_yticklabels(['-1', '0', '1'])
plot.show()
#</code>

produces a figure with 3 color bands (blue,green,red) and matching color bar with labels (-1,0,1) as expected.

if the data[160:]=1 specification is deleted, in the above code, the resulting figure has 2 color bands (blue,red) and the associated color bar is identical to the original, but the labels are (-1,0).

What I want, in this second case, is a blue-green figure and a color bar with labels identical to the original example.

-- jv
------------------------------------------------------------------------

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to