Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 将常规标题添加到autoplot.lm_R_Ggplot2_Lm_Ggfortify - Fatal编程技术网

R 将常规标题添加到autoplot.lm

R 将常规标题添加到autoplot.lm,r,ggplot2,lm,ggfortify,R,Ggplot2,Lm,Ggfortify,我正在使用autoplot绘制回归模型的诊断图。我想为图表添加一个通用的单一标题 例如: library(ggfortify) autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3) 我想在顶部放置一个“标题”,而不修改任何子地块。提前谢谢 编辑:我已经尝试了grid.arrange()获取此错误:$中的错误使用gridExtra&grid包怎么样 library(gridExtra) library(gri

我正在使用autoplot绘制回归模型的诊断图。我想为图表添加一个通用的单一标题

例如:

library(ggfortify)
autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)
我想在顶部放置一个“标题”,而不修改任何子地块。提前谢谢


编辑:我已经尝试了grid.arrange()获取此错误:$中的错误使用
gridExtra
&
grid
包怎么样

library(gridExtra)
library(grid)
title1=textGrob("Title", gp=gpar(fontface="bold"))
grid.arrange(plot1, plot2, plot3, plot4, 
             top=title1)

我会写这样的代码。

您可以直接引用
ggmultiplot
对象中的ggplot对象列表,该对象由
ggfortify
autoplot.lm
返回:

p <- autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)

gridExtra::grid.arrange(grobs = p@plots, top = "some title")

p谢谢您的快速回答。很抱歉没有提及,但我已经尝试了grid.arrange()获取此错误:中的错误$