[R-SIG-Mac] png and dpi

Tim Cole tim.cole at ich.ucl.ac.uk
Fri Sep 10 11:59:16 CEST 2010


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()

or

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

both produce plots of 7x7 in, 2100x2100 pixels, 72 ppi. So here dpi=300 
is overruled with dpi=72.

The plot resolution is correct throughout, but writing directly to file 
the dpi is wrong. Is there a way to force the file to have dpi=300?

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

Thanks,
Tim

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