There is a cook.levels
parameter that controls how many and for what values the dotted lines are produced. Its length also used in the if
statment that leads to the branch which produces the legend. Therefore if you set the value to NULL
you get rid of the dotted lines and the legend. You may also want to remove the solid red line by setting add.smooth=FALSE
.
plot(test, which=5, cook.levels=NULL, add.smooth=FALSE)
Edit
After suggestions in the question comment that only the legend is to be removed, editing a copy of plot.lm
seems to be the way to go. This question gives an effective, though slightly esoteric, way of doing so using body
:
plot.lm2 <- plot.lm
body(plot.lm2)[[27]][[3]][[9]][[4]][[8]][[3]][[6]]<-NULL
plot.lm2(test, which=5)