Search code examples
rpar

How to determine symbol size in x and y units


I would like to know the approximate dimensions of symbol in my plot area. I think that par()$ps only really refers to text size. So how is a symbol size calculated using the cex parameter? For example, below is a plot of a single point of size cex=10. Can i determine its size from the plot devices par parameters?

plot(50, 50, ylim=c(0,100), xlim=c(0,100), cex=10)

#click on outer x limits
p1 <- locator(n=1,typ="n")
p2 <- locator(n=1,typ="n")

#approx width in x units(~15)
abs(p1$x - p2$x)

Thanks for you help. -Marc


Solution

  • According to the documentation contained in ?par, we have that,

    • cin - R.O.; character size (width, height) in inches. These are the same measurements as cra, expressed in different units.
    • cra - R.O.; size of default character (width, height) in ‘rasters’ (pixels). Some devices have no concept of pixels and so assume an arbitrary pixel size, usually 1/72 inch. These are the same measurements as cin, expressed in different units.

    On my machine, these values appear to be:

    par("cin")
    [1] 0.15 0.20
    > par("cra")
    [1] 10.8 14.4
    

    So character magnification via cex ought to happen relative to these dimensions, presumably by scaling the horizontal and vertical dimensions separately (although I don't know that for sure).