Re: How to shade area between two lines [message #29826] |
Fri, 22 March 2002 07:17 |
Charlie Zender
Messages: 8 Registered: October 1996
|
Junior Member |
|
|
> I don't understand what this means. Here is an example
> that seems to do what you want.
Thanks for the example, I'll see if this works.
I think I forgot to reverse() the points in the second line
so the polygon connected points it shouldn't have in the middle...
--
Charlie Zender, zender at uci dot edu, (949) 824-2987, Department of
Earth System Science, University of California, Irvine CA 92697-3100
|
|
|
Re: How to shade area between two lines [message #29831 is a reply to message #29826] |
Thu, 21 March 2002 12:17  |
Doug Rowland
Messages: 12 Registered: March 2002
|
Junior Member |
|
|
On 03/21/02 02:02 PM, in article MPG.1703ea2fb4d4c3d0989841@news.frii.com,
"David Fanning" <david@dfanning.com> wrote:
> Charlie Zender (zender@uci.edu) writes:
>
>> I have two lines on an xy plot. The horizontal axis is time.
>> One line is always above the other.
>> I would like to greyshade the area in between the lines.
>> How can this be done?
>
> Will PolyFill.
>
>> polyfill treats my vertices like a polygon,
>> and I do not want the last point connected to the first point.
>
> I don't understand what this means. Here is an example
> that seems to do what you want.
>
> ************************************************************ **
> PRO Example
>
> ; Create some data
>
> y1 = [ 1, 3, 2, 5, 6, 9]
> y2 = [ 3, 6, 7, 6, 8, 10]
> x1 = Indgen(6) + 1
> x2 = Indgen(6) + 1
>
> ; Load some colors.
>
> TVLCT, [125, 255, 0], [125,255, 255], [125, 0, 0], 100
> Device, Decomposed=0
>
> ; Draw the plot, fill the area between lines with gray.
>
> Plot, x1, y1, /NoData, XRange=[0,10], XStyle=1
> Polyfill, [x1, Reverse(x2)], [y1, Reverse(y2)], Color=100
> OPlot, x1, y1, Color=101
> Oplot, x2, y2, Color=102
>
> END
> ************************************************************ **
>
> Cheers,
>
> David
To handle missing data (represented by !VALUES.F_NAN or otherwise) you'd
first have to filter your data and interpolate.
Doug Rowland
rowland@fields.space.umn.edu
|
|
|
Re: How to shade area between two lines [message #29833 is a reply to message #29831] |
Thu, 21 March 2002 12:02  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Charlie Zender (zender@uci.edu) writes:
> I have two lines on an xy plot. The horizontal axis is time.
> One line is always above the other.
> I would like to greyshade the area in between the lines.
> How can this be done?
Will PolyFill.
> polyfill treats my vertices like a polygon,
> and I do not want the last point connected to the first point.
I don't understand what this means. Here is an example
that seems to do what you want.
************************************************************ **
PRO Example
; Create some data
y1 = [ 1, 3, 2, 5, 6, 9]
y2 = [ 3, 6, 7, 6, 8, 10]
x1 = Indgen(6) + 1
x2 = Indgen(6) + 1
; Load some colors.
TVLCT, [125, 255, 0], [125,255, 255], [125, 0, 0], 100
Device, Decomposed=0
; Draw the plot, fill the area between lines with gray.
Plot, x1, y1, /NoData, XRange=[0,10], XStyle=1
Polyfill, [x1, Reverse(x2)], [y1, Reverse(y2)], Color=100
OPlot, x1, y1, Color=101
Oplot, x2, y2, Color=102
END
************************************************************ **
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|