创建一个 y 轴有两条线的图表。我使用如下的 atop 函数:
plot + ylab(expressions(atop("Line 1","Line 2")))
想知道是否可以更改第一行的字体大小,比如使其比第二行更大?
谢谢!
plot + ylab(expression( atop(Line~1,
scriptstyle(Line~2))
))
expressions
函数,我将您的文本转换为真正的R表达式。您可以查看theme()设置来调整axis.title.y的element_text特性以增加文本大小。plot + ylab(expression( atop( Line~ 1,
scriptstyle( Line~ 2) ))) +
theme(axis.title.y = element_text( size = rel(2) ) )
除了plotmath
之外,您还可以使用grid
函数直接绘制文本:
library("gridExtra")
gt <- grobTree(ggplotGrob(plot + ylab("")), textGrob("Line 1", 0.01, 0.5, rot = 90, gp = gpar(fontsize = 18)), textGrob("Line 2", 0.025, 0.5, rot = 90, gp = gpar(fontsize = 10)))
plot.new()
grid.draw(gt)
atop
函数。请参见此问题的响应。 - Sandy Muspratt