[R-SIG-Mac] png and dpi

Tim Cole tim.cole at ich.ucl.ac.uk
Fri Sep 10 12:30:29 CEST 2010

Sorry, correction to my last post. ****

Here are various ways of creating a png file. The dpi seems to be 
treated inconsistently.

> quartz(width=7, height=7); plot(1:11); dev.copy2pdf()

produces a plot of 7x7 in, 2100x2100 pixels, 300 ppi. So dpi defaults to 
300 - fair enough ... But

> quartz(width=7, height=7, dpi=72); plot(1:11); dev.copy2pdf()

also produces a plot of 7x7 in, 2100x2100 pixels, 300 ppi. So dpi=72 is 
overruled with dpi=300.

Writing directly to file produces the opposite effect:

> quartz(width=7, height=7, type='png', dpi=300); plot(1:11); dev.off()


> png(width=7, height=7, units='in', res=300, type='quartz')
> plot(1:11); dev.off()

both produce plots of 29.2x29.2 in (NOT 7x7 as in previous post), **** 
2100x2100 pixels, 72 ppi. So here size and dpi are both overruled.

The plot resolution is correct throughout, but writing directly to file 
changes both the size and dpi. Is there a way to force the file to have 

I'm on R 2.11.1 GUI 1.34 Leopard build 32-bit (5589).


Tim.Cole at ich.ucl.ac.uk Phone +44(0)20 7905 2666 Fax +44(0)20 7905 2381
MRC Centre of Epidemiology for Child Health,
UCL Institute of Child Health, London WC1N 1EH, UK

More information about the R-SIG-Mac mailing list