comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: shading in contour plots
items: Re: shading in contour plots

shading in contour plots
type: item
description: 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.
creator: c.hoyle
date: 2005-07-10T09:04:49-00:00

Re: shading in contour plots
type: item
description: 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/
creator: David Fanning
date: 2005-07-10T10:02:48-00:00

Re: shading in contour plots
type: item
description: > 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
creator: c.hoyle
date: 2005-07-11T08:36:58-00:00

Re: shading in contour plots
type: item
description: 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
creator: David Fanning
date: 2005-07-11T09:00:29-00:00

Re: shading in contour plots
type: item
description: "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
creator: R.G. Stockwell
date: 2005-07-11T15:46:21-00:00

Re: shading in contour plots
type: item
description: > 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.
creator: c.hoyle
date: 2005-07-13T07:34:04-00:00