[R] one problem about how to hold graphic with R

Liaw, Andy andy_liaw at merck.com
Tue Oct 31 15:17:04 CET 2006


I'm not familiar with Matlab, but from what I know, "hold on" is used to
overlay more stuff on the existing plot.  In R such things are
accomplished a bit differently:  One put up a plot, then use things like
lines(), points(), abline(), etc. to add to the existing plot.   The
closest thing to "hold on" in Matlab, I think, is par(new=TRUE).

Andy

From: Gavin Simpson
> 
> On Tue, 2006-10-31 at 21:36 +0800, yang baohua wrote:
> > Sorry to disturb you, but can you help me to solve one 
> little problem?
> > I want to draw a graphic after another with R but I cannot find the 
> > first one after that.
> > Do you know the command to hold the graphic with R?
> > I remember with Matlab you may use "hold on".
> > Thanks.
> > 
> > 
> 
> You don't say which OS. On MS Windows one can turn on a 
> history of plots to the graphics device and replay your plots 
> - it is in the menu bar for example.
> 
> In all OSes, you can start up a new device to take the plot - 
> which is what Matlab does IIRC, so you have two or more plot 
> windows on screen at any one time. This is done like this:
> 
> plot(1:10)
> x11()
> plot(1:20)
> x11()
> plot(rnorm(100))
> 
> see ?Devices
> 
> You can set a device to be active, i.e. switch around between 
> plotting windows using dev.set(), e.g.:
> 
> > dev.cur() # example from above leaves device 4 active
> X11
>   4
> > dev.set(3) # switch to device
> > dev.cur() # check
> X11
>   3
> > plot(sort(rnorm(100))) # plot something new on this device
> 
> Is this what you were looking for?
> 
> HTH
> 
> G
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Gavin Simpson                 [t] +44 (0)20 7679 0522
>  ECRC & ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
>  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
> 
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}



More information about the R-help mailing list