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

From: Petr Klasterecky <klaster_at_karlin.mff.cuni.cz>
Date: Mon 02 Apr 2007 - 13:36:28 GMT

Robert McFadden napsal(a):
>
>

>> -----Original Message-----
>> From: r-help-bounces@stat.math.ethz.ch 
>> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of 
>> Schmitt, Corinna
>> Sent: Monday, April 02, 2007 2:58 PM
>> To: r-help@stat.math.ethz.ch
>> Subject: [R] Device drivers - png()/jpeg()
>>
>> 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?

>
> png(file="plot_names.png") # for jpeg and pdf use:
> jpeg(file="plot_names.jpeg") and pdf((file="plot_names.pdf")
>
> 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.off()
>
> Rob

Most probably that will not work - interactive and batch-like modes were mixed ...

You'll have to decide whether you want/need to select coordinates interactively using locator() or not. If you do not need locator() and can provide the coordinates to abline() or other functions, use pdf(), jpeg() and png() as suggested above.

If you do need locator() and you are using a GUI for R (or a stabdard Windows interface for R - you didn't specify your OS), you can still select 'File -> Save as' in the main menu and save you plot manually.

Petr

>
> ______________________________________________
> 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.
>

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

______________________________________________
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 00:00:26 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 - 14:30:38 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.