将点 cex 转换为英寸、像素或 r 中的绘图坐标

convert point cex to inches, pixels, or plot coordinates in r

我正在尝试将 cex 中的点大小转换为图上的宽度和高度单位。我可以使用以英寸、像素或 xy 坐标为单位的单位。我发现了一些类似的东西来寻找字符的大小,但我找不到任何关于标绘点的东西。如果我可以在 cex = 1 使用 par() 时算出一个点的大小,那么我也可以计算不同比例的点的大小。

对于字符,获取高度和宽度:
par("cin") 英寸
par("cra") 像素
par("cxy")xy坐标

是否有类似的选项来获取点的大小?
或者,字符高度和宽度如何转换为点直径?

(注意这个类似问题How to determine symbol size in x and y units只回答字数,不回答分数。)

经过反复试验,点直径(xy坐标)似乎是字符高度除以2*pi。

char.height <- par("cxy")[2]
point.diam <- char.height / (2 * pi)
point.cex <- 7 # try changing and it still works
point.diam.cex <- point.diam * point.cex

plot(x = 0, y = 1, type = "n")
points(x = 0, y = 1, cex = point.cex, pch = 21, bg = "grey")
segments(x0 = 0 - (point.diam.cex/2), x1 = 0 + (point.diam.cex/2), y0 = 1, y1 = 1, col = "red")