Skip to content

dev.size() does not return correct size on 4K screen

3 messages · Martijn Tennekes, Peter Dalgaard

#
I don't know about RStudio, but in X11 this sort of thing can happen due to misconfiguration of the display itself, i.e. not in R as such. Basically, it relies on getting the correct dots-per-inch value from the display, and may otherwise use some standard value. 

What happens if you run xdpyinfo in a terminal window?

With XQuartz on an MB Air, I see

...
screen #0:
  dimensions:    1440x876 pixels (381x232 millimeters)
  resolution:    96x96 dots per inch
...

which is a multi-way lie! It is a 2560x1600 retina display, the resolution is way higher than 96x96, and it is 13.3", whereas the stated dimensions corresponds to a 17" diagonal. 

However, systems may be "lying in the users best interest", since e.g. the default for an X11() plot window is 7in square, which might not fit on a small laptop. You are somewhat more likely to want the same relative size across different laptops.  

- pd

  
    
#
Thank you, Peter!


 From xdpyinfo I got

screen #0:
 ? dimensions:??? 5120x2880 pixels (903x508 millimeters)
 ? resolution:??? 144x144 dots per inch

According to these specs my screen should have a sqrt((5120/144)^2 + 
(2880/144)^2) = 40.8" diagonal.

However, in practice it is 27", so that perfectly explains the 1.5 
factor difference.


In RStudio, dev.size() is not equal to par("fin"), which caused the 
problem for me. I the R terminal, these two are equal. I'll post this in 
the RStudio issue list.


Best,

Martijn
On 3/2/22 23:11, peter dalgaard wrote: