Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用自动绘图为回归模型绘制诊断图。我想为图表添加一个通用的单一标题。
例如:
library(ggfortify) autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)
我想在顶部放置一个“标题”而不修改任何子图。提前致谢。
编辑:我已经尝试 grid.arrange() 得到这个错误: $<-( tmp , wrapvp, value = vp) 中的错误:没有分配这个 S4 类的子集的方法。
您可以直接引用'sggmultiplot返回的对象中的 ggplot 对象列表:ggfortifyautoplot.lm
ggmultiplot
ggfortify
autoplot.lm
p <- autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3) gridExtra::grid.arrange(grobs = p@plots, top = "some title")
使用gridExtra&grid包怎么样?
gridExtra
grid
library(gridExtra) library(grid) title1=textGrob("Title", gp=gpar(fontface="bold")) grid.arrange(plot1, plot2, plot3, plot4, top=title1)
我会写这样的代码。