[R] Add points to subplots

David Winsemius dwinsemius at comcast.net
Fri Jun 13 03:12:32 CEST 2014


On Jun 12, 2014, at 8:06 AM, Luca Cerone wrote:

> Dear all,
> I am running some analysis using the pamr package (available on CRAN).
> 
> One of the plots I produce is made using the function "pamr.plotcv".
> This displays two plots in the same figure (using par(mfrow=c(2,1)).
> 
> When the figure is created, I would like to be able to add some points
> and lines, to the top plot.
> 
> After producing the plot with pamr.cvplot, I have tried to add a line
> doing something like:
> 
> par(mfg=c(1,1))
> lines(c(3,3), c(0,1), col = "blue", lty = 3)
> 
> However this doesn't work and the line is shown in the bottom plot.
> How can I add points and lines to the top plot?

I think you would be better off hacking the code and inserting your desired annotations before the focus is moved to the second region. There are split screen methods that allow changing focus for base graphics, but I'm not aware of ones that use the par() controls.

-- 

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list