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

> 
> 
> It is easy to modify the values of the second step of Colormapping:
> from pylab import *
> from numpy import *
> 
> def G(i,j):
>     return exp(-((i-100)**2+(j-100)**2)/50.)
> 
> def cmap_xmap(function,cmapInput):
>     cdict = cmapInput._segmentdata.copy()
>     function_to_map = lambda x : (function(x[0]), x[1], x[2])
>     for key in ('red','green','blue'):
>         cdict[key] = map(function_to_map, cdict[key])
>         cdict[key].sort()
>     return matplotlib.colors.LinearSegmentedColormap('MyMap',cdict,1024)
> 
> A=fromfunction(G,(200,200))
> imshow(A,cmap=cmap_xmap(lambda x:x**60,get_cmap("hot")))
> 
> but it does no help.
> 
> 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


------------------------------------------------------------------------------
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

Reply via email to