我无法在网上找到答案的快速问题(或威克姆的书):
ggplot2中size参数的单位是什么? 例如geom_text(size = 10)-以10为单位?
编辑:同一问题适用于ggsave(height = 10,width = 10)中的默认单位
- 2021-1-121 #
- 2021-1-122 #
'ggplot2'包(如之前的'lattice')是在
grid
上构建的 包.您可以在以下位置获得可用的单位:?grid::unit ?grid::convertX ?grid::convertY grid::convertX(grid::unit(72.27, "points"), "inches")
(我使用形式主义
pkg::func
因为在大多数情况下, 加载了一个名称空间,但在任一grid
时均未附加 或`ggplot2已加载。)我之前发布了一条评论,后来我删除了评论,说
lattice
很有意思.我看到size
的文本大小后才这样做 大约是10毫米 agstudy提到的"魔术"数实际上在以下值的1%之内:size=10
- 2021-1-123 #
来自
as.numeric(grid::convertX(grid::unit(1, "points"), "mm")) #[1] 0.3514598 0.352777778/.Last.value #[1] 1.00375
?aes_linetype_size_shape
# Size examples # Should be specified with a numerical value (in millimetres), # or from a variable source
和height
在ggsave中与width
有关 来自par("din")
?par
所以我猜
din R.O.; the device dimensions, (width, height), in inches. See also dev.size, which is updated immediately when an on-screen device windows is re-sized.
在size
以毫米和aes
ggsave
和height
英寸。width
相关问题
- r:在ggplot2中将构面标签更改为数学公式rggplot22021-01-12 01:28
- r:ggplot2条形图的多个子组rggplot22021-01-11 18:55
- r:通过过滤隐藏对象来减少绘图的PDF文件大小rpdfvectorplotggplot22021-01-10 19:26
- r:如何在ggplot2的构面中添加常规标签?rlabelfacetggplot22021-01-09 22:55
- r:ggplot结合了来自不同dataframes的两个图rggplot22021-01-09 10:25
答案是:单位是点.它是
grid
中fontsize的单位 包.在?unit
,我们发现以下定义(但请注意紧密相关的" bigpts"
Big Points. 72 bp = 1 in.
)内部
ggplot2
将字体大小乘以魔数ggplot2:::.pt
,定义为 1/0.352777778这里有个演示,我使用grid和ggplot2创建了一个大小相同的字母:
附录感谢@baptiste
"幻数"(在aaa-constants.r中定义为.pt<-1 / 0.352777778)实际上只是"点"和" mm"之间的转换因子,即
1/72 * 25.4 = 0.352777778
.不幸的是,grid
对" pts"和" bigpts"进行了细微的区分,这解释了为什么convertUnit(unit(1, "pt"), "mm", valueOnly=TRUE)
给出了0.3514598
的稍微不同的值