[R] jpeg and pixels

Marc Schwartz (via MN) mschwartz at mn.rr.com
Tue Feb 28 23:46:08 CET 2006


On Tue, 2006-02-28 at 16:10 -0600, Erin Hodgess wrote:
> Dear R People:
> 
> When using the jpeg function for plotting,
> is there a way to set the size in inches, please?
> 
> There is an option for width and height in pixels, but
> not inches.
> 
> 
> Any suggestions would be welcome!!!!!

The problem is that the size of the resultant image when using bitmaps
is entirely dependent upon the resolution (in pixels per inch) of the
device upon which it is displayed. This is also referred to as dpi or
dots per inch.

Thus, for example, on my system I have a dual display configuration. 

The laptop internal LCD (15 inch diag.) is running at 1600x1200 with a
dpi of 133.

My external LCD display is a 20.1 inch diag., also at 1600x1200, with a
dpi of 98.

Thus, a JPEG image that is 400 pixels x 400 pixels will be roughly 3
inches square on my laptop, but roughly 4 inches square on the external
display.

You need to know the target dpi of the display device and then calculate
the required pixels from there.

An alternative is to use the bitmap() function, where you can specify
height and width arguments, but also need to define the 'res' setting,
which is the dpi desired. Even here, the basic calculation process is
the same:

  Inches = Pixels / DPI


HTH.

Marc Schwartz




More information about the R-help mailing list