Re: [R] Device drivers - png()/jpeg()

From: Don MacQueen <macq_at_llnl.gov>
Date: Mon 02 Apr 2007 - 15:00:15 GMT

The locator() function, as its help page explains, returns the coordinates that were identified. So, you can do this:

plot(0:4,0:4, type = "n", xlab = "X-Werte", ylab = "Y-Werte")

points(rnorm(100), rnorm(100), col = "black")
tmp1 <- locator(2, type= "l")
tmp2 <- locator(2, type = "l", col = "red")
png()
plot(0:4,0:4, type = "n", xlab = "X-Werte", ylab = "Y-Werte")
points(rnorm(100), rnorm(100), col = "black")
points(tmp1, type= "l")
points(tmp2,type = "l", col = "red")

dev.off()

You could also use dev.copy(), as in:

plot(0:4,0:4, type = "n", xlab = "X-Werte", ylab = "Y-Werte") points(rnorm(100), rnorm(100), col = "black") locator(2, type= "l")
locator(2, type = "l", col = "red")
dev.copy(png)

-Don

At 2:58 PM +0200 4/2/07, Schmitt, Corinna wrote:
>Hallo R-experts,
>
>I produced a R graphic with the help of the following commands:
>
>plot(0:4,0:4, type = "n", xlab = "X-Werte", ylab = "Y-Werte")
>points(rnorm(100), rnorm(100), col = "black") locator(2, type= "l")
>locator(2, type = "l", col = "red")
>
>I could display this graphic by using windows() before entering those
>commands. Now I want to save this graphic as PNG file and JPEG file. I
>studied the online-help and the manuals extensively but could not find a
>solution.
>
>Can anyone tell me the corresponding command in detail?
>
>Thanks, Corinna
>
>______________________________________________
>R-help@stat.math.ethz.ch 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.

-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Tue Apr 03 01:11:23 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 02 Apr 2007 - 15:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.