繁体   English   中英

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

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

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

对于字符,获取高度和宽度:
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")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM