Re: How to plot many lines simultaneously [message #32729] |
Tue, 05 November 2002 21:47 |
Jeff Guerber
Messages: 41 Registered: July 2000
|
Member |
|
|
On Tue, 5 Nov 2002, David Fanning wrote:
> lily_zhang (fengliza@sina.com) writes:
>
>> Now I have two matrices, X and Y. Supposing X = FltArr(100), Y =
>> FltArr(8,100),
>> I just wonder how to plot all the columns of Y as the functions of X
>> in an image simultaneouly.
>
> I'd try something like this.
>
> Plot, x, y[0,*], YRange=[Min(y),Max(y)]
> FOR j=1,7 DO OPlot, x, y[j,*]
Lily, since no one else has mentioned this I'd just like to add that,
although it doesn't make a noticeable difference in this small example, if
you're doing this A LOT or the arrays are much bigger, it's much more
efficient if Y = FltArr(100,8) (and you make the corresponding changes to
David's programlet). Remember that in IDL, as in Fortran, the left index
varies the fastest.
Jeff Guerber
|
|
|
Re: How to plot many lines simultaneously [message #32731 is a reply to message #32729] |
Tue, 05 November 2002 13:45  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Pavel A. Romashkin (pavel_romashkin@hotmail.com) writes:
> This is plotting *subsequently*. For simultaneous, he'd have to do a
> Countour, huh?
> Am I being a little ... retentive? Sorry :-)
Talk about retentive. I got all hot and bothered this
morning that my FSC_COLOR program wouldn't allow me
to specify a vector of drawing colors in a way that
would allow me to loop in this little example I gave
this morning. I spent half the day adding that little
feature and more to some of my most stalwart programs. :-(
The example should have read:
d = FSC_Color(['charcoal', 'yellow'], Colors=c)
Plot, x, y[0,*], Color=c.charcoal, Background=c.yellow, /NoData
drawcolors = FSC_Color(['green', 'dodger blue', 'firebrick', $
'pale green', 'dark goldenrod', 'moccasin', 'orchid'])
FOR j=0,7 DO OPlot, x, y[j,*], Color=drawcolors[j]
Now, how's that for a half day's work!!
Cheers,
David
P.S. Let's just say even tennis coaching is beginning to
look lucrative to my wife. :-(
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
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
|
|
|
Re: How to plot many lines simultaneously [message #32732 is a reply to message #32731] |
Tue, 05 November 2002 13:00  |
Pavel A. Romashkin
Messages: 531 Registered: November 2000
|
Senior Member |
|
|
David Fanning wrote:
>
> lily_zhang (fengliza@sina.com) writes:
>
>> Now I have two matrices, X and Y. Supposing X = FltArr(100), Y =
>> FltArr(8,100),
>> I just wonder how to plot all the columns of Y as the functions of X
>> in an image simultaneouly.
>
> I'd try something like this.
>
> Plot, x, y[0,*], YRange=[Min(y),Max(y)]
> FOR j=1,7 DO OPlot, x, y[j,*]
This is plotting *subsequently*. For simultaneous, he'd have to do a
Countour, huh?
Am I being a little ... retentive? Sorry :-)
Cheers,
Pavel
|
|
|
Re: How to plot many lines simultaneously [message #32736 is a reply to message #32732] |
Tue, 05 November 2002 06:34  |
R.G. Stockwell
Messages: 363 Registered: July 1999
|
Senior Member |
|
|
lily_zhang wrote:
> Now I have two matrices, X and Y. Supposing X = FltArr(100), Y =
> FltArr(8,100),
> I just wonder how to plot all the columns of Y as the functions of X
> in an image simultaneouly.
plot,x,y(0,*)
for i= 1,7 do oplot,x,y(i,*)
Cheers,
bob
PS
X = findgen(100)
Y = randomn(seed,8,100)
creates a far more interesting plot than your example
|
|
|
Re: How to plot many lines simultaneously [message #32740 is a reply to message #32736] |
Tue, 05 November 2002 05:20  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
lily_zhang (fengliza@sina.com) writes:
> Now I have two matrices, X and Y. Supposing X = FltArr(100), Y =
> FltArr(8,100),
> I just wonder how to plot all the columns of Y as the functions of X
> in an image simultaneouly.
I'd try something like this.
Plot, x, y[0,*], YRange=[Min(y),Max(y)]
FOR j=1,7 DO OPlot, x, y[j,*]
You probably want each plot in a different color or
line style so you can tell them apart, but just add
the appropriate keywords.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
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
|
|
|