Exporting graphs in high-resolution image formats – PNG, JPEG, BMP, and TIFF
In this recipe, we will learn how to save graphs in high-resolution image formats for use in presentations and publications.
Getting ready
We will only use the base graphics functions for this recipe. So, just run the R code at the R prompt. You might wish to save the code as an R script so that you can use it again later.
How to do it...
Let's re-create a simple scatter plot example from Chapter 1, R Graphics, and save it as a PNG file 600 px high and 600 px wide with a resolution of 200 dots per inch (dpi):
png("cars.png",res=200,height=600,width=600) plot(cars$dist~cars$speed, main="Relationship between car distance and speed", xlab="Speed (miles per hour)",ylab="Distance ...
Get R: Data Analysis and Visualization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.