Alan,

It sounds like what you want is a listed colormap with direct indexing 
using a NoNorm() instance as the norm:

aa = ones((2,3), dtype=int)
aa[0,0] = 0
aa[:,2] = 2
cmap = mpl.colors.ListedColormap(['k', 'r', 'b'])
norm = mpl.colors.NoNorm()
matshow(aa, cmap=cmap, norm=norm, interpolation='nearest')

The array has to be one of the integer dtypes.

Also see examples/colorbar_only.py if you want to use a colorbar--but I 
suspect you won't for your present application.

Eric

Alan G Isaac wrote:
> I have an integer array.
> The number of different integers is small,
> so small that I would like to define an
> integer to color mapping and use this
> with matshow.  E.g.,
> 0 -> black
> 1 -> red
> 2 -> blue
> etc
> 
> Possible?
> 
> Thank you,
> Alan Isaac
> 
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
> Don't miss this year's exciting event. There's still time to save $100. 
> Use priority code J8TL2D2. 
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to