以下是我编写的一个复杂自定义函数的简化示例。在完整形式的函数中,
"layer1"
对应于用户输入的caption
,"layer2"
对应于统计测试结果,以及"layer3"
对应于所进行的统计测试的详细信息。
library(ggplot2)
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(substitute(
atop("layer1", "layer2")
)
, "layer3")))
该示例创建于2018年11月09日,使用了 reprex package (v0.2.1)
我想找到一种方法,使得三个层级的文本大小保持不变。实际上,我不确定为什么在这种情况下文本大小会自动更改。
有没有办法阻止这种情况发生?
displaystyle(x)
和textstyle(x)
函数(有什么理由更喜欢前者而不是后者吗?)。我得到的行为是因为plotmath
默认为scriptstyle(x)
或scriptscriptstyle(x)
? - Indrajeet Patildisplaystyle
,因为在LaTeX文档中,行内公式比显示公式略小,这正是解决问题的方法。现在看起来textstyle
将会有更少的间距,所以你可以看看哪个更好。我猜默认值是scriptstyle
,如果你添加了atop
,它将变成scriptscriptstyle
。 - Julius Vainora