--- Begin Message ---
fred wrote:
Hi,

Please look at the short example attached showing the issue.

I want to display only one contour line, with value 0.8.

Obviously, the color associated with this contour line is bad
(blue instead of red color).

I think the reason is that the contour has its own colormap,
so for only one value, the color is blue.

I don't see anything about this issue in the contour help.

How can I fix this ?

At first I thought you wanted to draw a contour line on both the image and the colorbar, which you would do this way:

imshow(a)
cb = colorbar()
cs = contour(a, [0.8])
cb.add_lines(cs)

But then I looked at your message again and realized this is not what you want. If you do what you seem to be saying you want to do, you will end up with a nearly invisible line: if you use color mapping to determine the color of the contour line, and you put it on the image, it will of course not stand out very well. Here is how you would do it:

im = imshow(a)
cb = colorbar()
cs = contour(a, [0.8], norm = im.norm, cmap=im.cmap)
cb.add_lines(cs)

Is this in fact what you want? If nothing else, it illustrates how you can control the colormap and associated norm (scaling function) used by contour.

Eric


Thanks in advance.

Cheers,


------------------------------------------------------------------------

#! /usr/bin/env python

from scipy import *
from pylab import *

x, y = ogrid[-3:3:10*1j,-3:3:10*1j]

a = cos(x)*sin(y)

imshow(a)
colorbar()
contour(a, [0.8])
show()


------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/


------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--- End Message ---
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to