我已经注意到,当你添加一个包含小写字母q,y,p,g,j的标题时,这个图的维数会被修改。

缩放

*红线已手动加入。
如您所见,当我将上面的一个字母添加到标题中时,情节的高度会变小。
如何在不同标题的几个情节之间保持高度不变?
用于生成两个地块的代码:
# plot 1
ggplot(mpg, aes(factor(cyl), hwy)) +
geom_point(size=4) +
theme_bw() +
ggtitle("main")
# plot 2
ggplot(mpg, aes(factor(cyl), hwy)) +
geom_point(size=4) +
theme_bw() +
ggtitle("pmain")发布于 2017-09-07 06:59:24
您可以添加一个虚幻的小写字母,但这需要将文本转换为可能有一些不利之处的图解表达式。
.st <- function(s){
bquote(phantom("tp")*.(s))
}
# plot 1
p1 <- ggplot(mpg, aes(factor(cyl), hwy)) +
geom_point(size=4) +
theme_bw() +
ggtitle(.st("main"))
# plot 2
p2 <- ggplot(mpg, aes(factor(cyl), hwy)) +
geom_point(size=4) +
theme_bw() +
ggtitle(.st("pmain"))
grid.arrange(p1,p2,ncol=2)

https://stackoverflow.com/questions/46075326
复制相似问题