Baoqiang Cao
2012-Nov-27 15:46 UTC
[R] in par(mfrow=c(1, 2)), how to keep one half plot static and the other half changing
Hi, I'm trying to plot something in the following way and would like if you could help: I'd like in a same plot window, two plots are shown, the left one is a bird-view plot of the whole data, the right half keep changing, i.e., different plots will be shown up on request, so that when I select/click on some where in the left plot, the right plot will be the corresponding plot. What I did is: par(mfrow=c(1,2)) plot(x, y) while(1) { ... pxy <- locator(1, type="p") #select data point (dx,dy) based on pxy for a new plot .. plot(dx,dy) } I ended up with the left plot is overwritten by plot(dx,dy). Is there anyway to keep the left side intact while changing plots on the right side? Thanks a lot! Baoqiang
Duncan Murdoch
2012-Nov-28 00:02 UTC
[R] in par(mfrow=c(1, 2)), how to keep one half plot static and the other half changing
On 12-11-27 10:46 AM, Baoqiang Cao wrote:> Hi, > > I'm trying to plot something in the following way and would like if > you could help: > > I'd like in a same plot window, two plots are shown, the left one is a > bird-view plot of the whole data, the right half keep changing, i.e., > different plots will be shown up on request, so that when I > select/click on some where in the left plot, the right plot will be > the corresponding plot. > > What I did is: > > par(mfrow=c(1,2)) > plot(x, y) > > while(1) { > ... > pxy <- locator(1, type="p") > > #select data point (dx,dy) based on pxy for a new plot > .. > > plot(dx,dy) > } > > I ended up with the left plot is overwritten by plot(dx,dy). Is there > anyway to keep the left side intact while changing plots on the right > side? >Yes, use the "mfg" option of par(). For example, par(mfrow=c(1,2)) plot(1) for (i in 1:100) { par(mfg=c(1,2)) plot(i) } Since this overplots each time, you may need something fancy to clear the display (e.g. see ?rect). Duncan
Greg Snow
2012-Nov-28 18:52 UTC
[R] in par(mfrow=c(1, 2)), how to keep one half plot static and the other half changing
Duncan showed the way to do it in 1 plotting device, but it may be easier to just open 2 graphics devices, arrange them side by side, then set up the code to let you select in one, then switch to the other to do the plotting. See ?dev.new and ?dev.set. On Tue, Nov 27, 2012 at 8:46 AM, Baoqiang Cao <bqcaomail@gmail.com> wrote:> Hi, > > I'm trying to plot something in the following way and would like if > you could help: > > I'd like in a same plot window, two plots are shown, the left one is a > bird-view plot of the whole data, the right half keep changing, i.e., > different plots will be shown up on request, so that when I > select/click on some where in the left plot, the right plot will be > the corresponding plot. > > What I did is: > > par(mfrow=c(1,2)) > plot(x, y) > > while(1) { > ... > pxy <- locator(1, type="p") > > #select data point (dx,dy) based on pxy for a new plot > .. > > plot(dx,dy) > } > > I ended up with the left plot is overwritten by plot(dx,dy). Is there > anyway to keep the left side intact while changing plots on the right > side? > > > Thanks a lot! > > Baoqiang > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Gregory (Greg) L. Snow Ph.D. 538280@gmail.com [[alternative HTML version deleted]]