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

Home » Public Forums » archive » stippling or cross hatching in contour plot
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
stippling or cross hatching in contour plot [message #56149] Fri, 05 October 2007 14:26 Go to next message
MA is currently offline  MA
Messages: 15
Registered: August 2005
Junior Member
I have a couple of maps (contour plots with filled, colored contours)
that I'd like to overlay with stippling or hatching without blocking
the color underneath. Does anybody have a suggestion on this problem?
I'm trying to mark areas with high or low significance in the plot. A
simple contour doesn't work very well since the data is pretty noisy,
and I end up getting a lot of lines.

The only way to hatch things that I've found is with the c_orientation
keyword in the contour procedure. My problem with that is that it will
always hatch above the topmost defined level. I.e. if I want to hatch
between values of 25 and 50, and set levels=[25,50], it will hatch
above 50 as well. Also, it erases the colors underneath the hatched
portions.

Or should I use polyfill instead? I've done stippling before by
defining a pattern for polyfill. I think this would cover over the
underlying color contours, too. Unless I redefine the pattern in each
box with the correct color...

Any suggestions?
Thanks!
Re: stippling or cross hatching in contour plot [message #56272 is a reply to message #56149] Mon, 08 October 2007 13:22 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
Ok, maybe I am not getting this right...
is this what you are trying to achieve?

a=dist(100,100)
contour,a,level=[30,40,50,60,70]
contour,a,level=[30,40,50],c_orient=[0,45],/cell_fill,/
noerase,max_value=50

Ciao,
Paolo


MA wrote:
> Hello David,
> thanks, that's definitely an improvement. However, I'm still trying to
> hatch only between two levels (significant areas), not hatch all over
> the plot. I've modified your code a bit, and now it's working. I
> basically create a new array from the original, in which I set all
> points I want to hatch to 1, all points I don't want to hatch over to
> 0, then contour at levels 1 and above.
>
> ;*********************************************************** **********
> ;; create some data
> array=dist(10,10)
>
> Window,2
> loadct,2
> ;; contour data with color
> loadct, 33, ncolors=5, bottom=1
> device, decomposed=0, get_decomposed=theState
>
> thisDevice = !D.Name
> xsize = !D.X_Size
> ysize = !D.Y_Size
> Set_Plot, 'Z'
> Device, Set_Resolution=[xsize,ysize], Z_Buffer=0
> contour,array,levels=indgen(5),c_colors=indgen(5)+1,/fill, $
> xstyle=1, ystyle=1, position=[0.1, 0.1, 0.9, 0.9]
> ;; try to put hatching on top
> locx = [0.1, 0.9] * xsize
> locy = [0.1, 0.9] * ysize
> snap1 = TVRD(locx[0], locy[0], locx[1]-locx[0]+1, $
> locy[1]-locy[0]+1)
> ;; create new array for hatching
> newarray=array
> ;; set points I want to hatch over to 1
> newarray[Where(array GT 2.5 AND array LT 5.)]=1.
> ;; set points I don't want to hatch over to 0
> newarray[Where(array le 2.5 OR array ge 5.)]=0.
> ;; contour level=1 and some value above, which results in
> ;; hatching only over the area where the original array
> ;; had values between 2.5 and 5.
> contour, newarray,levels=[1,2],/overplot, $
> c_orientation=[45]
> snap2 = TVRD(locx[0], locy[0], locx[1]-locx[0]+1, $
> locy[1]-locy[0]+1)
>
> Set_Plot, thisDevice
> contour,array, xstyle=1, ystyle=1, /NoData, $
> position=[0.1, 0.1, 0.9, 0.9]
> TV, snap1 > snap2, locx[0], locy[0]
> device, decomposed=theState
> end
> ;*********************************************************** ***
Re: stippling or cross hatching in contour plot [message #56274 is a reply to message #56149] Mon, 08 October 2007 12:30 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
MA writes:

> thanks, that's definitely an improvement. However, I'm still trying to
> hatch only between two levels (significant areas), not hatch all over
> the plot. I've modified your code a bit, and now it's working. I
> basically create a new array from the original, in which I set all
> points I want to hatch to 1, all points I don't want to hatch over to
> 0, then contour at levels 1 and above.

Ah, yes, I see. Each hatching layer is a complete polyfill
that fills ALL the areas above it. (And none below it.)
The polyfills are layered onto one another from bottom
to top. So what you are doing seems reasonable.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: stippling or cross hatching in contour plot [message #56275 is a reply to message #56149] Mon, 08 October 2007 11:48 Go to previous message
MA is currently offline  MA
Messages: 15
Registered: August 2005
Junior Member
Hello David,
thanks, that's definitely an improvement. However, I'm still trying to
hatch only between two levels (significant areas), not hatch all over
the plot. I've modified your code a bit, and now it's working. I
basically create a new array from the original, in which I set all
points I want to hatch to 1, all points I don't want to hatch over to
0, then contour at levels 1 and above.

;*********************************************************** **********
;; create some data
array=dist(10,10)

Window,2
loadct,2
;; contour data with color
loadct, 33, ncolors=5, bottom=1
device, decomposed=0, get_decomposed=theState

thisDevice = !D.Name
xsize = !D.X_Size
ysize = !D.Y_Size
Set_Plot, 'Z'
Device, Set_Resolution=[xsize,ysize], Z_Buffer=0
contour,array,levels=indgen(5),c_colors=indgen(5)+1,/fill, $
xstyle=1, ystyle=1, position=[0.1, 0.1, 0.9, 0.9]
;; try to put hatching on top
locx = [0.1, 0.9] * xsize
locy = [0.1, 0.9] * ysize
snap1 = TVRD(locx[0], locy[0], locx[1]-locx[0]+1, $
locy[1]-locy[0]+1)
;; create new array for hatching
newarray=array
;; set points I want to hatch over to 1
newarray[Where(array GT 2.5 AND array LT 5.)]=1.
;; set points I don't want to hatch over to 0
newarray[Where(array le 2.5 OR array ge 5.)]=0.
;; contour level=1 and some value above, which results in
;; hatching only over the area where the original array
;; had values between 2.5 and 5.
contour, newarray,levels=[1,2],/overplot, $
c_orientation=[45]
snap2 = TVRD(locx[0], locy[0], locx[1]-locx[0]+1, $
locy[1]-locy[0]+1)

Set_Plot, thisDevice
contour,array, xstyle=1, ystyle=1, /NoData, $
position=[0.1, 0.1, 0.9, 0.9]
TV, snap1 > snap2, locx[0], locy[0]
device, decomposed=theState
end
;*********************************************************** ***
Re: stippling or cross hatching in contour plot [message #56278 is a reply to message #56149] Mon, 08 October 2007 09:47 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Whoops! Sorry. trying to do too many things at once.

Try this code.

;; create some data
array=dist(10,10)

Window,2
loadct,2
;; contour data with color
loadct, 33, ncolors=5, bottom=1
device, decomposed=0, get_decomposed=theState

thisDevice = !D.Name
xsize = !D.X_Size
ysize = !D.Y_Size
Set_Plot, 'Z'
Device, Set_Resolution=[xsize,ysize], Z_Buffer=0
contour,array,levels=indgen(5),c_colors=indgen(5)+1,/fill, $
xstyle=1, ystyle=1, position=[0.1, 0.1, 0.9, 0.9]
;; try to put hatching on top
locx = [0.1, 0.9] * xsize
locy = [0.1, 0.9] * ysize
snap1 = TVRD(locx[0], locy[0], locx[1]-locx[0]+1, $
locy[1]-locy[0]+1)

contour, array,levels=indgen(5),/overplot, $
c_orientation=[30,45,-30,-45,0]
snap2 = TVRD(locx[0], locy[0], locx[1]-locx[0]+1, $
locy[1]-locy[0]+1)

Set_Plot, thisDevice
contour,array, xstyle=1, ystyle=1, /NoData, $
position=[0.1, 0.1, 0.9, 0.9], levels=indgen(5)
TV, snap1 > snap2, locx[0], locy[0]
device, decomposed=theState
end

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: stippling or cross hatching in contour plot [message #56279 is a reply to message #56149] Mon, 08 October 2007 09:28 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
MA writes:

> Still, the problem remains that c_orientation will apply its hatching
> to all levels above the ones specified. Run the code above and see
> what I mean.

Humm. You may be right. OK, we have to be more creative. :-)

I didn't understand your example, but here is another
that demonstrates how to get cross-hatching on top of
colors. The cross-hatching appears to me to be exactly
where I expect it to be.

Cheers,

David

;*********************************************************** **********
;; create some data
array=dist(10,10)

Window,2
loadct,2
;; contour data with color
loadct, 33, ncolors=5, bottom=1
device, decomposed=0, get_decomposed=theState

thisDevice = !D.Name
xsize = !D.X_Size
ysize = !D.Y_Size
Set_Plot, 'Z'
Device, Set_Resolution=[xsize,ysize], Z_Buffer=0
contour,array,levels=indgen(5),c_colors=indgen(5)+1,/fill, $
xstyle=1, ystyle=1, position=[0.1, 0.1, 0.9, 0.9]
;; try to put hatching on top
locx = [0.1, 0.9] * xsize
locy = [0.1, 0.9] * ysize
snap1 = TVRD(locx[0], locy[0], locx[1]-locx[0]+1,
locy[1]-locy[0]+1)

contour, array,levels=[0,2.5,5.0],/overplot, $
c_orientation=[45,-45,0]
snap2 = TVRD(locx[0], locy[0], locx[1]-locx[0]+1, $
locy[1]-locy[0]+1)

Set_Plot, thisDevice
contour,array, xstyle=1, ystyle=1, /NoData, $
position=[0.1, 0.1, 0.9, 0.9],
TV, snap1 > snap2, locx[0], locy[0]
device, decomposed=theState
end
;*********************************************************** ***

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: stippling or cross hatching in contour plot [message #56280 is a reply to message #56149] Mon, 08 October 2007 09:08 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
Have you tried to use /cell_fill rather than /fill ?

Ciao,
Paolo


MA wrote:
> Hello David,
> thanks for your comments. Here's a very short piece of code to
> illustrate my problem.
>
> ;; create some data
> array=FindGen(100)
> array=Reform(array,10,10)
>
> Window,2
> loadct,2
> ;; contour data with color
> contour,array,levels=indgen(100),c_colors=indgen(100)+1,/fil l
> ;; try to put hatching on top
> contour, array,levels=[0,15,25],c_orientation=[45,-45,0],/fill,/
> noerase
> end
>
>> As usual with IDL contours, you can't let IDL choose the contours
>> for you. You have to choose them yourself, and the lowest one better
>> be conincident with the MIN(data) if you expect to make sense of
>> what you are doing. :-)
> I've done that
>
>
>> I don't see how it can erase the colors underneath, unless
>> you forget to use the NOERASE keyword.
> You were right, I forgot the NOERASE
>
> Still, the problem remains that c_orientation will apply its hatching
> to all levels above the ones specified. Run the code above and see
> what I mean. All levels above 0 are hatched at 45deg angle, all levels
> above 15 are hatched at 45 AND -45 deg angle, and all levels above 25
> are hatched at 45, -45 and 0deg angle. If I specify only one value for
> c_orientation=45, then the whole plot ends up being hatched at 45deg.
> I can't figure out how to hatch only between 0 and 15, or 15 and 25,
> for example.
>
> I've tried using POLYFILL instead, with the pattern keyword, and
> defining the pattern as a solid color for points where I don't want
> stippling, and defining the pattern as solid color with a couple of
> black dots where I do want stippling. It works, but the plot ends up
> being made up of lots of little squares, which doesn't look as smooth
> as the contour plot.
>
> I hope this explanation is a little clearer.
> Thanks!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Wanted: 4D multi-variate Data w/ u,v,w & t.
Next Topic: Re: moving to objects / IDL objects and object graphics

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

Current Time: Wed Oct 08 14:01:09 PDT 2025

Total time taken to generate the page: 0.00632 seconds