I am creating a subplot with a function that I called smallPlot . It sets par(fig) to the graph sub-region (or drawing for multi-channel graphs). However, after resetting the parameters, mtext slightly off. Any idea why this is happening?
dev.off() plot(1:10) mtext("hello", adj=1, col=2) # written as expected op4 <- par(fig=c(0.1,0.8,0.3,0.8), new=TRUE) par(op4) mtext("hello ", adj=1, col=3) # right spot par(fig=c(0.1,0.8,0.3,0.8), new=TRUE) plot(rnorm(400), type="l") par(op4) mtext("hello ", adj=1, col=4) # too far left
Edit: The original question was different, but easily resolved. Here it is for reference:
dev.off() op1 <- par(no.readonly = TRUE) plot(1:10) abline(h=2, col=2) # drawn par(fig=c(0.1,0.8,0.3,0.8), new=TRUE) plot(rnorm(400), type="l") par(op1) abline(h=4, col=4) # not drawn! axis(4)
Answer: op1$usr - 0,1,0,1 by default.
source share