Eric Firing wrote: > Xavier Gnata wrote: >> Hi, >> >> I'm trying to modify the imshow colormapping on the flight: >> >> http://matplotlib.sourceforge.net/api/colors_api.html?highlight=linearsegmentedcolormap#matplotlib.colors.Normalize >> >> >> "Colormapping typically involves two steps: a data array is first >> mapped onto the range 0-1 using an instance of Normalize >> <http://matplotlib.sourceforge.net/api/colors_api.html?highlight=linearsegmentedcolormap#matplotlib.colors.Normalize> >> >> or of a subclass; then this number in the 0-1 range is mapped to a >> color using an instance of a subclass of Colormap >> <http://matplotlib.sourceforge.net/api/colors_api.html?highlight=linearsegmentedcolormap#matplotlib.colors.Colormap>" >> >> >> >> How should I modify the way "data array is first mapped onto the >> range 0-1"? >> I would like to map all the values <T1 to 0, all the values>T1 to 1 >> and use an affine function to map all the others values into ]0,1[. >> In a more generic way, how should I modify the way the normalization >> step is >> <http://matplotlib.sourceforge.net/api/colors_api.html?highlight=linearsegmentedcolormap#matplotlib.colors.Normalize> >> >> performed? >> I could modify the values to be displayed but it is ugly. > > Functions and methods that take cmap kwargs also take norm kwargs; > they work together. The Normalize subclass instance passed in via the > norm kwarg is what does the mapping of the original data to the 0-1 > range. For examples, see lib/matplotlib/colors.py, which has the > Normalize base class and the LogNorm, BoundaryNorm, and NoNorm > subclasses. > > Eric Ok. So I just create class MyNorm(matplotlib.colors.Normalize) and call imshow(A,cmap=cmap_xmap(lambda x:x,get_cmap("hot")),norm=MyNorm) That looks easy :) Thanks.
Xavier ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users