2010/3/27 Ariel Rokem <aro...@berkeley.edu>:
> I am trying to make a color-map which will respond to the range of values in
> the data itself. That is - I want to take one of the mpl colormaps and use
> parts of it, depending on the range of the data.
>
> In particular, I am interested in using the plt.cm.RdYlBu_r colormap. If the
> data has both negative and positive values, I want 0 to map to the central
> value of this colormap (a pale whitish yellow) and I want negative values to
> be in blue and positive numbers to be in red. Also - I would want to use the
> parts of the colormap that represent how far away the smallest and largest
> values in the data are from 0. So - if my data is in the range [x1,x2] I
> would want to use the part of the colormap in indices
> 127-127*abs(x1)/(x2-x1) through 127+127*x2/(x2-x1). If the data only
> includes positive numbers, I would want to only use the blue part of the
> colormap and if there are negative numbers, I would want to only use the red
> part of the colormap (in these cases, I would also want to take only a
> portion  of the colormap which represents the size of the interval [x1,x2]
> relative to the interval [0,x1] or [x2,0], as the case may be).
>
> I think that this might be useful when comparing matrices generated from
> different data, but with the same computation, such as correlation or
> coherence (see http://nipy.sourceforge.net/nitime/examples/fmri.html to get
> an idea of what I mean).

I might miss something important, but why not use pcolor() with kwargs
vmin and vmax,
http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.pcolor,
e.g.:

maxval = numpy.abs(C).max()
pcolor(C, vmin = -maxval, vmax = maxval)

As far as I can judge, this should have the desired effect.

Friedrich

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to