Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

Re: [R] saving graphics in jpeg format

Prof Brian Ripley

2006-11-22

Replies:

On Tue, 21 Nov 2006, Paulo Barata wrote:

> Dear R users,
>
> I need to save a graph in jpeg format. After plotting the graph,
> when the graphics window is active, in the File menu, the
> Save as / Jpeg / 100% quality correctly saves the graph in jpeg format.
> But I would like to know, how could I control the resolution (in dpi)
> of the saved jpeg file? I need to produce a jpeg at 1200 dpi.

jpeg files do not have a dpi: they are dimensioned in pixels. I think you
mean you want a file at 1200 ppi (pixels per inch), as 'dpi' (dots per
inch) is a printer parameter (sometimes also used of monochrome screens).

> I have tried also the jpeg function in the package grDevices.
> A simple command like this works correctly:
>
> jpeg(filename="test01.jpg", width = 800, height = 600, quality = 100,
>   pointsize = 250)
> barplot(1:5,col=1:5)
> dev.off()
>
> But I can't figure out the relation between pointsize, pixels, points
> and dpi. For example, to be specific, to save a graph measuring
> width = 6 inches, height = 4 inches, at 1200 dpi, which parameters
> should I use in the jpeg function?

width=6*1200, height=4*1200, res=1200

Note that 1200ppi is a very high resolution, and 200dpi is more usual.

Please take local advice on this issue, as I believe the problem is a
misunderstanding of resolution.

--
Brian D. Ripley,            ripley@(protected)
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford,         Tel: +44 1865 272861 (self)
1 South Parks Road,              +44 1865 272866 (PA)
Oxford OX1 3TG, UK           Fax: +44 1865 272595

______________________________________________
R-help@(protected)
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.
©2008 r-help.com - Jax Systems, LLC, U.S.A.