Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
helen (bin_zheng_99@yahoo.com) writes: > I have a problem about using plots. I want to use two plots for two > different data sets at the same time. If I just use one plots for one > data set, there is no problem. But when I use two, it doesn't work. It > seems the two plots interrupt each other. I want to know why? I really can't tell what you are trying to do, but if you put a couple of plots into your code so you have a good reference point, it appears you are at least plotting into both windows. I've never seen the CONTINUE keyword before, and can't really tell what it does (or is suppose to do) in this program. pro testPlots arrayT = fltarr(11) arrayX = fltarr(11) arrayY = fltarr(11) window, 1 plot,[0,10],[-10,10], /NoData x1 = !X & y1 = !Y & p1 = !P window,2 plot,[0,10],[-5,5], /NoData x2 = !X & y2 = !Y & p2 = !P for I=0, 10 Do begin arrayY[I] = cos(I+1) arrayX[I] = sin(I+1) arrayT[I] = I wset, 1 !X = x1 & !Y = x1 & !P = p1 plots,arrayT[I], arrayX[I], /continue wset, 2 !X = x2 & !Y = y2 & !P = p2 plots,arrayT[I], arrayY[I], /continue endfor end Does this give you any clues!? Are you trying to do this? arrayT = fltarr(11) arrayX = Sin(fltarr(11) + 1) arrayY = Cos(fltarr(11) + 1) Window,3, arrayT, arrayX Window, 4, arrayT, arrayY 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
> I have a problem about using plots. I want to use two plots for two > different data sets at the same time. If I just use one plots for one > data set, there is no problem. But when I use two, it doesn't work. It > seems the two plots interrupt each other. I want to know why? > > Thanks very much for any kind of help! > > I attach my simple program below: > > ;***************** > pro testPlots > arrayT = fltarr(11) > arrayX = fltarr(11) > arrayY = fltarr(11) > window, 1 > x1 = !X & y1 = !Y & p1 = !P > window,2 > x2 = !X & y2 = !Y & p2 = !P > for i=0, 10 Do begin > arrayY[i] = cos(i+1) > arrayX[i] = sin(i+1) > arrayT[i] = i > wset, 1 > !X = x1 & !Y = x1 & !P = p1 > plots,arrayT[i], arrayX[i], /continue > wset, 2 > !X = x2 & !Y = y2 & !P = p2 > plots,arrayT[i], arrayY[i], /continue > > endfor > > end > The /continue is telling the routine to start plotting from where the last plots was performed. When you are changing wingows the routine is continuing the plot from the point where the other window left off. If you want to plot in this manner, I would suggest letting your program keep track of where you left off. for i=0, 10 Do begin arrayY[i] = cos(i+1) arrayX[i] = sin(i+1) arrayT[i] = i if i gt 0 then begin wset, 1 !X = x1 & !Y = x1 & !P = p1 plots, arrayT[[i-1,i]], arrayX[[i-1,i]] wset, 2 !X = x2 & !Y = y2 & !P = p2 plots, arrayT[[i-1,i]], arrayY[[i-1,i]] end endfor Don
helen wrote: > Hello, All, > > I have a problem about using plots. I want to use two plots for two > different data sets at the same time. If I just use one plots for one > data set, there is no problem. But when I use two, it doesn't work. It > seems the two plots interrupt each other. I want to know why? > > Thanks very much for any kind of help! > > I attach my simple program below: > > ;***************** > pro testPlots > arrayT = fltarr(11) > arrayX = fltarr(11) > arrayY = fltarr(11) > window, 1 > x1 = !X & y1 = !Y & p1 = !P > window,2 > x2 = !X & y2 = !Y & p2 = !P > for i=0, 10 Do begin > arrayY[i] = cos(i+1) > arrayX[i] = sin(i+1) > arrayT[i] = i > wset, 1 > !X = x1 & !Y = x1 & !P = p1 > plots,arrayT[i], arrayX[i], /continue > wset, 2 > !X = x2 & !Y = y2 & !P = p2 > plots,arrayT[i], arrayY[i], /continue > > endfor > > end > > ;**************************** How about: arrayT = fltarr(11) arrayX = fltarr(11) arrayY = fltarr(11) window, 1 plot,[0,10],[-10,10], /NoData,title='plot 1' x1 = !X & y1 = !Y & p1 = !P window,0 plot,[0,10],[-5,5], /NoData,title='plot 2' x2 = !X & y2 = !Y & p2 = !P for I=1, 10 Do begin arrayY[I] = cos(I+1) arrayX[I] = sin(I+1) arrayT[I] = I endfor for I=0, 10-1 Do begin wset, 1 plots,arrayT[I], arrayX[I] plots,arrayT[I+1], arrayX[I+1], /continue wset, 0 plots,arrayT[I], arrayY[I] plots,arrayT[I+1], arrayY[I+1], /continue endfor end Cheers, bob
David Fanning <david@dfanning.com> wrote in message news:<MPG.17cb6d6733fc1915989969@news.frii.com>... > helen (bin_zheng_99@yahoo.com) writes: > >> I have a problem about using plots. I want to use two plots for two >> different data sets at the same time. If I just use one plots for one >> data set, there is no problem. But when I use two, it doesn't work. It >> seems the two plots interrupt each other. I want to know why? > > I really can't tell what you are trying to do, but if you > put a couple of plots into your code so you have a good > reference point, it appears you are at least plotting > into both windows. I've never seen the CONTINUE keyword > before, and can't really tell what it does (or is suppose > to do) in this program. > > pro testPlots > arrayT = fltarr(11) > arrayX = fltarr(11) > arrayY = fltarr(11) > window, 1 > plot,[0,10],[-10,10], /NoData > x1 = !X & y1 = !Y & p1 = !P > window,2 > plot,[0,10],[-5,5], /NoData > x2 = !X & y2 = !Y & p2 = !P > for I=0, 10 Do begin > arrayY[I] = cos(I+1) > arrayX[I] = sin(I+1) > arrayT[I] = I > wset, 1 > !X = x1 & !Y = x1 & !P = p1 > plots,arrayT[I], arrayX[I], /continue > wset, 2 > !X = x2 & !Y = y2 & !P = p2 > plots,arrayT[I], arrayY[I], /continue > > endfor > end > > Does this give you any clues!? > > Are you trying to do this? > > arrayT = fltarr(11) > arrayX = Sin(fltarr(11) + 1) > arrayY = Cos(fltarr(11) + 1) > Window,3, arrayT, arrayX > Window, 4, arrayT, arrayY > > Cheers, > > David Hello, David, Thanks David for your help. But I still have not solved my problem. My problem is whether I can plot two different data in two windows at the same time? Because I want to track a target's movement and display its x (arrayX) and y (arrayY) position against the time (arrayT) at the real time. So that I can see the moving from the plots in these two windows. So, I write a simple program to test if I can plot two different data (arrayX against arrayT, arrayX against arrayT) at the same time and still get correct result? Is there a way to do this? Thanks very much for any suggestion!
helen wrote: > David Fanning <david@dfanning.com> wrote in message > news:<MPG.17cb6d6733fc1915989969@news.frii.com>... >> helen (bin_zheng_99@yahoo.com) writes: >> >>> I have a problem about using plots. I want to use two plots for two >>> different data sets at the same time. If I just use one plots for one >>> data set, there is no problem. But when I use two, it doesn't work. It >>> seems the two plots interrupt each other. I want to know why? >> >> I really can't tell what you are trying to do, but if you >> put a couple of plots into your code so you have a good >> reference point, it appears you are at least plotting >> into both windows. I've never seen the CONTINUE keyword >> before, and can't really tell what it does (or is suppose >> to do) in this program. >> >> pro testPlots >> arrayT = fltarr(11) >> arrayX = fltarr(11) >> arrayY = fltarr(11) >> window, 1 >> plot,[0,10],[-10,10], /NoData >> x1 = !X & y1 = !Y & p1 = !P >> window,2 >> plot,[0,10],[-5,5], /NoData >> x2 = !X & y2 = !Y & p2 = !P >> for I=0, 10 Do begin >> arrayY[I] = cos(I+1) >> arrayX[I] = sin(I+1) >> arrayT[I] = I >> wset, 1 >> !X = x1 & !Y = x1 & !P = p1 >> plots,arrayT[I], arrayX[I], /continue >> wset, 2 >> !X = x2 & !Y = y2 & !P = p2 >> plots,arrayT[I], arrayY[I], /continue >> >> endfor >> end >> >> Does this give you any clues!? >> >> Are you trying to do this? >> >> arrayT = fltarr(11) >> arrayX = Sin(fltarr(11) + 1) >> arrayY = Cos(fltarr(11) + 1) >> Window,3, arrayT, arrayX >> Window, 4, arrayT, arrayY >> >> Cheers, >> >> David > > Hello, David, > > Thanks David for your help. But I still have not solved my problem. My > problem is whether I can plot two different data in two windows at the > same time? Because I want to track a target's movement and display its > x (arrayX) and y (arrayY) position against the time (arrayT) at the > real time. So that I can see the moving from the plots in these two > windows. So, I write a simple program to test if I can plot two > different data (arrayX against arrayT, arrayX against arrayT) at the > same time and still get correct result? Is there a way to do this? > > Thanks very much for any suggestion! Dear Helen, this a normal common problem and may be I can help. idl saves always only the last state of coordination vars of a window to several system variables. So there is a transformation matrix neccesary for each window you create depending on sizes, type and range. The routines savesysvar and restsysvar are doing this for you. After "plot" in first window or in your example creation of the window you have to store the system vars by p1=savesysvar() and for the second window plot into p2. If you now actualize first window you have to restore their belonging system variables by restsysvar,p1 and if you switch to plot on the other window you have to set restsysvar,p2 http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/restsysvar.tar.gz http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/savesysvar.tar.gz or as idl 5.5 binary http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/restsysvar.sav http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/savesysvar.sav (Remember a idl compiled file with the extension sav is automaticly loaded the first time it is used. This is the same behaviour as for idl sources (.pro). They run on each idl platform with the same idl version) For further routines and licensing please have a look at http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html best regards Reimar pro test arrayT = fltarr(11) arrayX = fltarr(11) arrayY = fltarr(11) window, 1 ;x1 = !X & y1 = !Y & p1 = !P p1=savesysvar() window,2 ;x2 = !X & y2 = !Y & p2 = !P p2=savesysvar() for i=0, 10 Do begin arrayY[i] = cos(i+1) arrayX[i] = sin(i+1) arrayT[i] = i wset, 1 restsysvar,p1 ; !X = x1 & !Y = x1 & !P = p1 plots,arrayT[i], arrayX[i], /continue wset, 2 restsysvar,p2 ; !X = x2 & !Y = y2 & !P = p2 plots,arrayT[i], arrayY[i], /continue endfor end -- Forschungszentrum Juelich email: R.Bauer@fz-juelich.de http://www.fz-juelich.de/icg/icg-i/ ============================================================ ====== a IDL library at ForschungsZentrum Juelich http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
helen (bin_zheng_99@yahoo.com) writes: > Thanks David for your help. But I still have not solved my problem. My > problem is whether I can plot two different data in two windows at the > same time? Because I want to track a target's movement and display its > x (arrayX) and y (arrayY) position against the time (arrayT) at the > real time. So that I can see the moving from the plots in these two > windows. So, I write a simple program to test if I can plot two > different data (arrayX against arrayT, arrayX against arrayT) at the > same time and still get correct result? Is there a way to do this? I think I would drop the CONTINUE keyword and just draw from the last point to this point: pro testPlots arrayT = fltarr(11) arrayX = fltarr(11) arrayY = fltarr(11) window, 1 plot,[0,10],[-10,10], /NoData x1 = !X & y1 = !Y & p1 = !P window,2 plot,[0,10],[-10,10], /NoData x2 = !X & y2 = !Y & p2 = !P for I=1, 10 Do begin arrayY[I] = cos(I+1) arrayX[I] = sin(I+1) arrayT[I] = I wset, 1 !X = x1 & !Y = y1 & !P = p1 plots,[arrayT[i-1], arrayT[I]], $ [arrayX[i-1], arrayX[I]] wset, 2 !X = x2 & !Y = y2 & !P = p2 print, [arrayY[i-1], arrayY[I]] plots,[arrayT[i-1], arrayT[I]], $ [arrayY[i-1], arrayY[I]] endfor end This works perfectly, as far as I can tell. 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
Helen, IDL is more elegant than you suppose. I would suggest using arrays rather than FOR loops. (David meant findgen() rather then fltarr(), I assume.) With the plots outside of a loop, you won't need to use the /continue keyword. Whenever I need to set up a plot and then draw the plot in two steps, I use the /data keyword. Then you don't need to hassle with !X, !Y, and the like. This is done in testPlots2 below. An even more compact version is in testPlots3 below. This may or may not work for you, but I combine the creation of the plot and the actual plotting into one step using plot rather than plot & plots. They keywords to plot let you choose the domain and range (x and y) yourself, and the ystyle=1 setting allows you to force the use of [-5,5] rather than the automatically-selected [-6,6]. pro testPlots2 window, 1 plot,[0,10],[-10,10], /NoData window,2 plot,[0,10],[-5,5], /NoData I = findgen(11) arrayY = cos(I+1) arrayX = sin(I+1) arrayT = I wset, 1 plots, arrayT, arrayX, /data wset, 2 plots, arrayT, arrayY, /data end pro testPlots3 I = findgen(11) arrayY = cos(I+1) arrayX = sin(I+1) arrayT = I window, 1 plot, arrayT, arrayX, /data, xrange=[0,10], yrange=[-10,10] window, 2 plot, arrayT, arrayY, /data, xrange=[0,10], yrange=[-5,5], ystyle=1 end I hope this points you in the right direction, M. Katz