[R] Add points to subplots
Jim Lemon
jim at bitwrit.com.au
Sat Jun 14 02:13:45 CEST 2014
On Fri, 13 Jun 2014 12:02:34 PM Luca Cerone wrote:
> Thanks David,
> I already did this, but in case the code gets updated I will have to
> re-add the annotation, which I do not think it is ideal.
>
> I was just wondering if there is an easy solution to this.
> Thanks a lot for the help,
>
Hi Luca,
I decided to try using the split.screen function, which I had previously
tried without getting what I wanted. This example:
split.screen(c(2,1))
screen(1)
screen()
plot(1:7)
screen(2)
plot(1:6)
screen(1,FALSE)
screen()
points(x=7:1,y=1:7,col="red")
when run with no graphics devices currently open, seems to work and do
what you want. When I first tried it on an open device (x11) it would not
switch screens properly, remaining on the top (first) screen despite calls
to screen() that reported that the screen had changed. I tried this after
opening a png device and it also worked correctly, so I think that if you
are careful to initialize the graphics device immediately before
split.screen it should do it.
Jim
More information about the R-help
mailing list