[R] Using dev.copy
Paul Murrell
p.murrell at auckland.ac.nz
Wed Mar 24 23:12:09 CET 2010
Hi
Dan Davison wrote:
> I'm working over an ssh connection without X11 graphics. I'm making a
> plot, the first stage of drawing which takes a long time. I want to
> experiment with adding details. Here is what I was hoping to do, which
> results in error.
>
> ## Draw the master plot on png dev 2
> png(file="master.png")
> plot(1:10)
>
> ## Save a copy on png dev 3
> png(file="copy1.png")
> dev.set(2)
> dev.copy(which=3)
>
> ## Add details to copy, write to disk and view
> abline(v=5)
> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
> plot.new has not been called yet
>
> Can someone tell me how to do this correctly?
The problem is that the "display list" is turned off by default for
png() devices, so there is no record of what has been drawn, so when you
do dev.copy(), there is nothing to copy. If you turn the display list
on, it should work much better ...
png(file="master.png")
## TURN DISPLAY LIST ON
dev.control("enable")
plot(1:10)
## Save a copy on png dev 3
png(file="copy1.png")
dev.set(2)
dev.copy(which=3)
## Add details to copy, write to disk and view
abline(v=5)
... hope that helps.
Paul
> Thanks a lot,
>
> Dan
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-help
mailing list