I'm plotting diagnostics plots for a regression model using autoplot. I would like to add a general single title for the graph.
As example:
library(ggfortify)
autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)
I would like to place a "Title" at the top without modifying any subplot. Thanks in advance.
EDIT: I already tried grid.arrange() getting this error: Error in $<-(tmp, wrapvp, value = vp) : no method for assigning subsets of this S4 class.
You can directly reference the list of ggplot objects within the ggmultiplot
object returned by ggfortify
's autoplot.lm
:
p <- autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)
gridExtra::grid.arrange(grobs = p@plots, top = "some title")