It appears that when plotting in split screens, R does not remember the
range of the axes in the plots. For example, split the screen and create a
plot in screen(1), say 'plot(1:10,1:10)'. Then switch from screen(1) to
screen(2) and create another plot. Now switching back to screen(1) and
attempting to add points with the 'points' command causes the points to
plot
incorrectly. It seems that the axes from the original plot are not
remembered.
A workaround seem to be re-issuing the original plot command with the
type="n" option: 'plot(1:10,1:10,type="n")'.
I found this by moving working code from S-Plus 2000 into R v1.5.1 and a
particular interactive plot I use began drawing incorrectly.
I took the following code directly from the 'split.screen' help page in
R
and modified one line to highlight the problem I encountered.
Thanks,
Chris Bodily
#---------------------------------------------------------------------------
-----------
if (interactive()) {
par(bg = "white") # default is likely to be transparent
split.screen(c(2,1)) # split display into two screens
split.screen(c(1,2),2) # split bottom half in two
plot(1:10) # screen 3 is active, draw plot
erase.screen() # forgot label, erase and redraw
plot(1:10, ylab= "ylab 3")
screen(1) # prepare screen 1 for output
plot(1:10)
screen(4) # prepare screen 4 for output
plot(1:10, ylab="ylab 4")
screen(1, FALSE) # return to screen 1, but do not clear
# plot(10:1,axes=FALSE, pch=2,col=5, lty=2, ylab="") # overlay
second
plot
## Problem here as the following points get plotted incorrectly ##
## it seems that the axes are reset ##
points(rep(3,10),1:10,col=2,pch=2) # add a few more points for a test
axis(4) # add tic marks to right-hand axis
title("Plot 1")
close.screen(all = TRUE) # exit split-screen mode
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._