I would like to customise diagnostic plots in ggplot2. I have tried this:
library(ggfortify)
library(ggplot2)
model1 <- lm(len~dose*supp, data = ToothGrowth)
autoplot(model1, which = 1, label.size = 3, data = ToothGrowth, size=3, colour = "dose",
smooth.colour = 'darkblue', smooth.linetype="dotted", smooth.linesize=3)
I got this picture:
I changed the line colour and line type for smoother line, but I do not know how can I change the line width. I have tried "smooth.linesize", but it is not working. It is possible somehow change the line width?
Can somebody help me? Thank You.
One option would be to add another layer to your plot since
autoplot.lm
does not provide the desired argumentsmooth.linesize
. The first part generates your plot,p
.The desired data of the smoothed line can now be found somewhere deep inside
p
here:p@plots[[1]]$layers[[2]]$data
This can be used as the
data
argument in the call togeom_*
. The following code generates the plot below.Another option would be to add the not yet existing aesthetics parameter
size
to the respective layer of the plot object yourself. I guess this option is closer to what you want to achieve.This can be done via
I hope this helps.