comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: very simple but weird problem with CONTOUR
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: very simple but weird problem with CONTOUR [message #81274] Sat, 01 September 2012 16:25
mxfong2012 is currently offline  mxfong2012
Messages: 5
Registered: September 2012
Junior Member
Thanks a lot, David and Phillip!
I didn't recognize that there was a difference between /cell_fill and /fill options. I then made experiments using the combination of /cell_fill and NaN, and my problem was solved. I will also look into David's routine library.
Thanks, and have a wonderful holiday weekend!
Re: very simple but weird problem with CONTOUR [message #81276 is a reply to message #81274] Sat, 01 September 2012 15:20 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mxfong2012@gmail.com writes:

> Thanks, David, for your response! I am sorry that I don't get it. What did you mean by "your first contour
> is going to be drawn at 1.0"? In my example, I have 6 levels ranging from 0 to 1. By setting max_value=0.5, my intention was to draw the contours only at the levels of 0, 0.2, and 0.4. Please forgive the newbie question, as most of my research is on numerical calculations, and didn't have many experiences on IDL plotting.

My apologies. I was heading out the door and confused the c_levels
variable with the levels variable. Sorry.

Basically, I wouldn't be using the MAX_VALUE keyword
with a contour plot, because "missing values" will be
ignored by the contour algorithm. The result is always
unpredictable, and rarely what you had in mind. If you
want to contour only the first three contours, then just
pass the first three contours to the LEVELS keyword.

And, if I were new to IDL, I'd be using Coyote Graphics
routines, rather than the normal IDL direct graphics
routines. Things will make a good deal more sense to you. :-)

http://www.idlcoyote.com/graphics_tips/coyote_graphics.php

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: very simple but weird problem with CONTOUR [message #81277 is a reply to message #81276] Sat, 01 September 2012 14:32 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
Keep in mind this snippet from IDL help:

Data points with values above this value are ignored (i.e., treated as missing data) when contouring. Cells containing one or more corners with values above MAX_VALUE will have no contours drawn through them.

Increasing 6 to a larger number (say, 60) will yield *something* using the original snippet (but I would check your position keyword in the call to contour :-) )

Alternatively, try using /CELL_FILL instead of /FILL. You should get *something* then as well.

You might try clamping the array z (by using contour, z < 0.5, x, y, ...), but this may not be exactly what you want either.

While I'm here, let me recommend using Coyote's cgContour instead. No 'LoadCt' commands necessary in this case.
Re: very simple but weird problem with CONTOUR [message #81278 is a reply to message #81277] Sat, 01 September 2012 13:25 Go to previous message
mxfong2012 is currently offline  mxfong2012
Messages: 5
Registered: September 2012
Junior Member
Thanks, David, for your response! I am sorry that I don't get it. What did you mean by "your first contour
is going to be drawn at 1.0"? In my example, I have 6 levels ranging from 0 to 1. By setting max_value=0.5, my intention was to draw the contours only at the levels of 0, 0.2, and 0.4. Please forgive the newbie question, as most of my research is on numerical calculations, and didn't have many experiences on IDL plotting.
Re: very simple but weird problem with CONTOUR [message #81280 is a reply to message #81278] Sat, 01 September 2012 11:41 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mxfong2012@gmail.com writes:

> I ran into a very simple but weird problem with CONTOUR. In the below example, everything was fine if I used "max_value=1". But when I changed it to "max_value=0.5", I had nothing but a black window. What is wrong? Am I missing anything here? I am using IDL Version 7.0.4, Mac OS X (darwin x86_64 m64)
>
> Thanks for any advices!
>
> example codes:
>
> X=findgen(6)/5.*2.-1.
> Y=X
> Z=randomu(1001L, 6,6)
>
> xrange=[-1,1]
> yrange=[-1,1]
> clevels=[1, 50, 100, 150, 200, 254]
> levels=[0, 0.2, 0.4, 0.6, 0.8, 1.0]
> loadct, 39
>
> plot, xrange, yrange, position=[0.1, 0.1, 0.9, 0.9], xstyle=5, ystyle=5, /nodata, /noerase
> contour, Z, X, Y, position=[0.1, 0.9, 0.1, 0.9], levels=levels, c_colors=clevels, /fill, /overplot, $
> xrange=xrange, yrange=yrange, xstyle=5, ystyle=5, xtitle='', ytitle='', max_value=0.5

If your maximum level is 0.5, and your first contour
is going to be drawn at 1.0, then all you can expect
to see is the background (black) of your contour plot. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Horizontal Histogram Plots
Next Topic: Cost of student version of IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:48:46 PDT 2025

Total time taken to generate the page: 0.00523 seconds