shading in contour plots [message #44648] |
Sun, 10 July 2005 02:04  |
c.hoyle
Messages: 3 Registered: July 2005
|
Junior Member |
|
|
Hi,
Is it possible to create an accurate, filled contour plot with data
which does not vary smoothly?
Im trying to create a contour plot of trend data. I would like to add
some shading in a single colour to indicate where the trends are
significant, i.e. I have a 2-d array filled with 1s and 0s, and call
contour with this array and the /cell_fill keyword. If I use
levels=[1], I get a plot composed of large rectangular patches, even
though the data is rather finely gridded, and the significance is not
distributed in large rectangular areas. If I change the levels to
levels=[0.1,1.], the plot looks completely different (much larger
shaded areas), despite the fact that there are only ones and zeros in
the array I'm plotting. Anyone got an idea of what Im doing wrong
here?
Cheers,
Chris.
|
|
|
Re: shading in contour plots [message #44702 is a reply to message #44648] |
Wed, 13 July 2005 00:34  |
c.hoyle
Messages: 3 Registered: July 2005
|
Junior Member |
|
|
> Offhand, you can try some other approaches, such as something like:
> IDL> shade_surf,sf,shade=bytscl(sf),az=0,ax=90,ztickname=strarr(2 0)+' '
>
> where you may want to fiddle with the byte scaling. If you data is 0 and 1,
> you could just do a "shade = sf*250" or something like that.
> Also, one could use tvimage or tv to plot the image (again with appropriate
> bytscling)
>
> However, if you want to accurately shade every rectangle, you may want to
> polyshade each region by itself (easy for rectangles, more difficult for
> arbitrary
> shapes).
>
> Cheers,
> bob
Good idea, I hadnt thought of that. I think TV will be the best bet.
thanks,
Chris.
|
|
|
Re: shading in contour plots [message #44725 is a reply to message #44648] |
Mon, 11 July 2005 08:46  |
R.G. Stockwell
Messages: 363 Registered: July 1999
|
Senior Member |
|
|
"C. Hoyle" <c.hoyle@pmodwrc.ch> wrote in message
news:470ec27d.0507110036.44976c0d@posting.google.com...
> I think this better describes my problem. Consider the following:
...
> If you only use levels 0 and 1, the line on the far left does not show
> up. If you use levels in between 1 and 0, the boundaries of the other
> rectangles are no longer properly defined. This is not such a problem
> with rectangles, but if the shapes are more complicated, then the
> result is not
> good. I dont think that this is a problem with nlevels (I dont use it)
> or /fill (I use /cell_fill).
> cheers,
> Chris
Offhand, you can try some other approaches, such as something like:
IDL> shade_surf,sf,shade=bytscl(sf),az=0,ax=90,ztickname=strarr(2 0)+' '
where you may want to fiddle with the byte scaling. If you data is 0 and 1,
you could just do a "shade = sf*250" or something like that.
Also, one could use tvimage or tv to plot the image (again with appropriate
bytscling)
However, if you want to accurately shade every rectangle, you may want to
polyshade each region by itself (easy for rectangles, more difficult for
arbitrary
shapes).
Cheers,
bob
|
|
|
Re: shading in contour plots [message #44739 is a reply to message #44648] |
Mon, 11 July 2005 02:00  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
C. Hoyle writes:
> If you only use levels 0 and 1, the line on the far left does not show
> up. If you use levels in between 1 and 0, the boundaries of the other
> rectangles are no longer properly defined. This is not such a problem
> with rectangles, but if the shapes are more complicated, then the
> result is not
> good. I dont think that this is a problem with nlevels (I dont use it)
> or /fill (I use /cell_fill).
Yes, I agree. The "problem" you seem to describe has to do with
how the program finds the "contour". In my experience, there are
*hundreds* of ways to do this, all of them correct (or incorrect,
I guess, as you please). But, in any case, not much you can do
if you choose to work with IDL. Although you might try ISOCONTOUR.
That uses yet another algorithm, I think.
Cheers,
David
|
|
|
Re: shading in contour plots [message #44740 is a reply to message #44648] |
Mon, 11 July 2005 01:36  |
c.hoyle
Messages: 3 Registered: July 2005
|
Junior Member |
|
|
> P.S. If you are still struggling, tell us something about
> the size of the array you are contouring and let us see
> the contour code you are using.
I think this better describes my problem. Consider the following:
;test the shading in contour plots:
JM=46
KM=25
inbetween=1 ;choose 1 for 3 levels or anything else for 2 levels.
sf=fltarr(JM,KM)
sf(20:21,10:15)=1.
sf(10:11,10:11)=1.
sf(5,10)=1.
sf(5,11)=1.
sf(5,12)=1.
;sf(*,*)=1
xr=[-90,90]
yr=[0,24]
IF inbetween EQ 1 THEN lev=[0.,0.5,1.] ELSE lev=[0.,1.]
IF inbetween EQ 1 THEN col=[0,100,182] ELSE col=[0,182]
lat_arr=findgen(JM)*4-90
alt=findgen(KM)
Contour,sf,lat_arr,alt,levels=lev,ystyle=1,xstyle=1,xrange=x r,$
yrange=yr,xtitle='Latitude',ytitle='Altitude
(km)',c_thick=3,charthick=3,charsize=1.2,$
/cell_fill,c_colors=col
oplot,[-10,-10],[0,25]
END
If you only use levels 0 and 1, the line on the far left does not show
up. If you use levels in between 1 and 0, the boundaries of the other
rectangles are no longer properly defined. This is not such a problem
with rectangles, but if the shapes are more complicated, then the
result is not
good. I dont think that this is a problem with nlevels (I dont use it)
or /fill (I use /cell_fill).
cheers,
Chris
|
|
|
Re: shading in contour plots [message #44747 is a reply to message #44648] |
Sun, 10 July 2005 03:02  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
C. Hoyle writes:
> Is it possible to create an accurate, filled contour plot with data
> which does not vary smoothly?
Depends entirely on the definition of "accurate", I suppose.
But if you are new to IDL, it's not likely. :-)
> Im trying to create a contour plot of trend data. I would like to add
> some shading in a single colour to indicate where the trends are
> significant, i.e. I have a 2-d array filled with 1s and 0s, and call
> contour with this array and the /cell_fill keyword. If I use
> levels=[1], I get a plot composed of large rectangular patches, even
> though the data is rather finely gridded, and the significance is not
> distributed in large rectangular areas. If I change the levels to
> levels=[0.1,1.], the plot looks completely different (much larger
> shaded areas), despite the fact that there are only ones and zeros in
> the array I'm plotting. Anyone got an idea of what Im doing wrong
> here?
I suspect just about everything, but this probably has more to do
with IDL and its documentation than it does with you. If you are
serious about filled contour plots, you might want to read these
articles:
http://www.dfanning.com/tips/contour_hole.html
http://www.dfanning.com/tips/contour_fill.html
http://www.dfanning.com/tips/nlevels.html
http://www.dfanning.com/color_tips/fill_colors.html
I suspect you *might* be able to get things to work, however,
if you tried setting your levels value to something like this:
levels = [0.0, 0.5]
Depending upon how small your array actually is, this will
probably give you some resemblance to what you are expecting
to see.
Cheers,
David
P.S. If you are still struggling, tell us something about
the size of the array you are contouring and let us see
the contour code you are using.
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|