Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plots with good resolution for printing and screen display

Tags:

plot

r

resolution

I was making my plots using

dev.new(width=5.8, height=3) 
par(mfrow=c(1,3),mar=c(1,1,2,1),oma=c(4,1,2,0),mgp=c(3, 0.5, 0)) 
plot(...)

and coping and pasting them into Microsoft Word. They look really good in Word (I tried different widths until I found one that worked well) but when I printed them they looked terrible. After some web searching I found the resolution for printing should be at least 300ppi. So after fiddling with widths and heights for an eternity I came out with code that makes the plots look the same size but with a better resolution:

png(file="mag_feb.png",width=1800,height=950,res=300)

They now look good when printed, but they don't look sharp at all in Word (on screen). Could it be a problem with size? Isn't there a way to make graphs that look good printed and on screen? I already spent hours with this and can't think of anything else to try, so any help will be very much appreciated!

Thanks!

like image 571
sbg Avatar asked Nov 17 '11 12:11

sbg


People also ask

How many pixels is good quality?

At 300 pixels per inch (which roughly translates to 300 DPI, or dots per inch, on a printing press), an image will appear sharp and crisp. These are considered to be high resolution, or high-res, images.

What is the standard recommended resolution for web images?

The standard resolution for web images is 72 PPI (often called “screen resolution”). At that size, the pixels you see on the screen are all the pixels there are; an image that's 4” long at 72 PPI will take up about 4” of your monitor.

How do I increase plot quality in R?

In base R, we can save a plot as a png and pass the resolution in the same stage. The procedure to do this is creating the png image with resolution with res argument then creating the plot and using dev. off() to create the file.


2 Answers

There is a small error in your original png command. Try this:

png(file="mag_feb.png", units="in", width=11, height=8.5, res=300)

Now, width and height are in inches, and res is in pixels/inch. Before, the res parameter was being ignored.

like image 159
bdemarest Avatar answered Oct 12 '22 11:10

bdemarest


You should be using a vector format, like PDF, for plots you will print. If the images look good when printed but not in Word, that is a problem with Word's downscaling feature. You might want to try using the vector Windows Metafile format to get things into Word.

like image 25
Michael Hoffman Avatar answered Oct 12 '22 13:10

Michael Hoffman