如果我使用\n
与labs(title="whatever \n comes after this")
我结束了与线之间相当大的空间。 有没有办法去影响它? (我的意思是,除了标题本身的字体大小)。
Answer 1:
你可以做这样的事情(选线高修改行间距)
p <- qplot(mpg, wt, data = mtcars)
p <- p + ggtitle("whatever \n comes after this") +
theme(plot.title = element_text(lineheight=.1))
p
Answer 2:
为了完美地中心的一切(其中\n
在一些情况下不会做),保持每一段文字相同的大小或者能够相对调整,如果有超过2线(在某些情况下是有用的),并在相同时间能够调整行间的空间,用这个来代替:
labs(title=expression(atop(textstyle("whateverline1"),atop(textstyle("whateverline2"),atop(scriptscriptstyle(""),textstyle("whateverline3"))))))
然后用labeller=label_parsed
这也适用于facet_grid
, xlab
和ylab
注意atop
和textstyle
的文字位置,同时保持它的所有相同的尺寸和scriptscriptstyle("")
来控制线之间的间距。 您还可以使用文本的不同的相对大小使用scriptstyle
或scriptscriptstyle
根据您的需要
文章来源: Change interlinear space in ggplot title?