Uwe Schmitt wrote:
> Hi,
> 
> I would like to plot contours with a nonlinear mapping from values to 
> color as follows:
> 
>    -1  ->  red
>     0  ->  white or green or black
>    +1  ->  red
> 
> How can I achieve this ?

See examples/contourf_demo.py.  The relevant part is this:

# Now make a contour plot with the levels specified,
# and with the colormap generated automatically from a list
# of colors.
levels = [-2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5]
CS3 = contourf(X, Y, Z, levels,
                         colors = ('r', 'g', 'b'),
                         origin=origin)

Try specifying 4 levels; I think this would do what you want (with black 
for the middle range, for example):

levels = [-1.5, -0.5, 0.5, 1.5]
CS = contourf(X, Y, Z, levels, colors=('r', 'k', 'r'))

Eric


> 
> Greetings, Uwe
>    
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to