[R] adding graphics after dev.copy
Giampiero Salvi
giampi at kth.se
Wed Feb 28 10:49:23 CET 2007
Hi,
I am trying to create a plot and save it as pdf to the file
file1.pdf, then add some details and save the new plot as file2.pdf.
I would like to avoid repeating all the instructions needed to create
file1.pdf when I create file2.pdf.
This is what I have tried:
pdf(file="file1.pdf")
plot(1:10)
dev.copy(pdf,file="file2.pdf")
points(2,3)
dev.off()
dev.off()
When I run points I get the error:
Error in plot.xy(xy.coords(x, y), type = type, ...) :
plot.new has not been called yet
When I try to do the same with the x11 device, it works:
x11()
plot(1:10)
dev.copy(x11)
points(2,3)
dev.off()
dev.off()
Can someone tell me what goes wrong in the first case and why the x11
and pdf devices behave differently?
Thank you!
Giampiero
More information about the R-help
mailing list