multi window switching [message #8462] |
Sat, 15 March 1997 00:00  |
williams
Messages: 7 Registered: March 1997
|
Junior Member |
|
|
I would like to open a number of plots with the !p.multi keyword, and
then place data points on each plot. Sounds simple, but then I would
like to add more data to each plot as time goes by.
The trouble is, I do not know how to tell IDL "go back to the first
(or nth) plot, and overplot there". This is such a trivial-seeming
task, can it be done? Each point that must be plotted cannot be
stored, so I really need to updata these plots, not make new ones.
Thanks,
Daniel Williams
+----------------------------------------------------------- ------------------+
|Daniel L. Williams | Email: williams@srl.caltech.edu |
|Space Radiation Lab| Telly: 818/395-6634 |
|Caltech 220-47 | Fax: 818/449-8676 |
|Pasadena, Ca 91125 | WWW: http://www.srl.caltech.edu/personnel/williams.html |
+----------------------------------------------------------- ------------------+
|
|
|
Re: multi window switching [message #8464 is a reply to message #8462] |
Fri, 14 March 1997 00:00   |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Daniel Williams writes:
> I would like to open a number of plots with the !p.multi keyword, and
> then place data points on each plot. Sounds simple, but then I would
> like to add more data to each plot as time goes by.
>
> The trouble is, I do not know how to tell IDL "go back to the first
> (or nth) plot, and overplot there". This is such a trivial-seeming
> task, can it be done?
Of course it can be done, Daniel. This is IDL we are talking about! :-)
The reason !P.MULTI is used to set up multiple plots on a page
is that it relieves the user of a lot of bookkeeping about
where to place the plot axes, how big to make the plot characters,
etc. In fact, !P.MULTI sets a lot of fields in the !P, !X, and !Y
system variables to do its job.
If you wish to overplot data on a plot other than the last one
that has been created with !P.MULTI then you have to know
how to restore these !P.MULTI-manipulated fields to their original
values when the plot was created. In practice this means saving the
!P, !X and !Y system variables after every plot, so they can be
restored for the plot of interest.
Here is an example for three plots, in which I overplot new data
on the second plot after drawing all three originally. The method
applies to any one of the three original plots.
Window, XSize=600, YSize=300
!P.MULTI = [0, 3, 1]
; Draw the first plot. Keep info.
PLOT, Findgen(11)
p1 = !P & x1 = !X & y1 = !Y
; Draw the second plot. Keep info.
PLOT, Findgen(11)
p2 = !P & x2 = !X & y2 = !Y
; Draw the third plot. Keep info.
PLOT, Findgen(11)
p3 = !P & x3 = !X & y3 = !Y
; Restore Plot2 info and overplot on the second plot.
!P = p2 & !X = x2 & !Y = y2
OPLOT, Reverse(Findgen(11))
Overplotting on any of the three plots is now just a matter
of restoring the appropriate system variables.
Cheers!
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
|
|
|
Re: multi window switching [message #8540 is a reply to message #8462] |
Tue, 18 March 1997 00:00  |
peter
Messages: 80 Registered: February 1994
|
Member |
|
|
Daniel Williams (williams@skrymir.srl.caltech.edu) wrote:
: I would like to open a number of plots with the !p.multi keyword, and
: then place data points on each plot. Sounds simple, but then I would
: like to add more data to each plot as time goes by.
: The trouble is, I do not know how to tell IDL "go back to the first
: (or nth) plot, and overplot there". This is such a trivial-seeming
: task, can it be done? Each point that must be plotted cannot be
: stored, so I really need to updata these plots, not make new ones.
You can do it by saving the !x, !y, !z and !p system variables after
performing each of the N plots, then setting these system variables back
to the saved values before over plotting the new points.
E.g. Try
IDL> !p.multi=[0,2,2]
IDL> plot, findgen(10)
IDL> x = !x
IDL> y = !y
IDL> z = !z
IDL> p = !p
IDL> plot, findgen(10)
IDL> !x =x
IDL> !y = y
IDL> !z = z
IDL> !p= p
IDL> oplot, 10-findgen(10)
It might seem that you could get away with saving only !p, but I think
this will only work if all the plots have the same axis ranges.
Peter
|
|
|