Skip to content
Prev 75948 / 398502 Next

Determining physical display dimensions

On Fri, 2005-08-19 at 13:17 -0500, Earl F. Glynn wrote:
FWIW, in case anyone should see this thread and wonder how to do this
somewhat easily in R for systems running X, there is a CLI utility
called 'xdpyinfo' that returns a great deal of data on the connected
display(s).
[1] "  dimensions:    1600x1200 pixels (301x231 millimeters)"
[1] "  resolution:    135x132 dots per inch"


One can then parse the above using R functions as required. Such as:
[1] ""            ""            "dimensions:" ""
[5] ""            ""            "1600"        "1200"
[9] "pi"          "els"         ""            "301"
[13] "231"         "millimeters"
h.pix, v.pix)
The current display is 1600 x 1200 pixels
with a physical size of 301 x 231 mm


This can get more complicated with multi-monitor systems, depending upon
whether you are running in xinerama (multi-monitor spanning mode) or
non-xinerama mode and consideration for symmetric or asymmetric
resolutions. 'man xdpyinfo' and 'man X' (noting the 'DISPLAY'
environment variable) will be helpful here to determine which
display/screen R is running on.

For example, on my system which has two displays, each with 1600x1200, I
get:
DISPLAY
 ":0.0"

with R running on the main laptop LCD (15" diag), versus:
DISPLAY
 ":0.1"

with R running on the external LCD (20.1" diag), with the DISPLAY
variable indicating:

":DisplayNumber.ScreenNumber"


Thus, on my system, the output of the system() calls are actually:
[1] "  dimensions:    1600x1200 pixels (301x231 millimeters)"
[2] "  dimensions:    1600x1200 pixels (411x311 millimeters)"
[1] "  resolution:    135x132 dots per inch"
[2] "  resolution:    99x98 dots per inch"


HTH,

Marc Schwartz