On 1/25/07, Prof Brian Ripley [EMAIL PROTECTED] wrote:
You asked
(or ultimately the dimension of the generated plot in pixels) without
know which of png(), jpeg() or bitmap() was used?
That is determined by arguments 'width' and 'height' in the call to the
device, and for the first two it is in pixels and for the third it is in
inches. Internally these are just numbers, and in particular the R
graphics system does not know the resolution to be used in pixelization.
Since some graphics parameters assume 'inches' and some 'pixels',
assumptions have to be made. png() assumes 96dpi and postscript() assumes
72dpi.
Thanks. That is useful to know.
You had the information you asked for, so why not just use it?
The function plotting does not know about the device, and I want to be
able to keep fixed-sized margins in the output (assuming bitmap
images).
R is not claiming to be your keeper.
That is one of the answers I expected and wanted to hear given that it
was the case.
/Henrik
On Thu, 25 Jan 2007, Henrik Bengtsson wrote:
Hi,
I am trying to infer the dimension of an opened bitmap (png, jpeg,
bitmap device...) from par() parmeters. From the help on par(), I
found that:
dim - c(400, 200)
png(foo.png, width=dim[1], height=dim[2])
dim2 - par(din) * par(cra) / par(cin)
dev.off()
dim2
[1] 399. 199.
I've tried the above on Rv2.4.1 on WinXP and Linux with png() and
jpeg() and the precision is good enough. However, when I turn to the
bitmap() device, I found the following:
s - 3; # Multiple of 72pt (default value of argument 'res' of bitmap())
res - s*72;
bitmap(foo.png, width=dim[1]/res, height=dim[2]/res, res=res)
dim2 - par(din) * par(cra) / par(cin)
dev.off()
dim/dim2
[1] 3 3
That is, dim/dim2 is not one, but equal to the multiple 's'. I
understand that this is because bitmap() is not a device per se and
utilized postscript() plus a call to ghostscript. But still, does
anyone know if it is possible to infer the correct resolution
res2 - s * par(cra) / par(cin)
(or ultimately the dimension of the generated plot in pixels) without
know which of png(), jpeg() or bitmap() was used? I know of
par(ps), but its unit is device specific.
Thanks
Henrik
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
--
Brian D. Ripley, [EMAIL 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, UKFax: +44 1865 272595
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel