Question: Assume this easy example:

```
> numberofdrugs <- rpois(84, 5)
> healthvalue <- rpois(84, 75)
> test <-glm(healthvalue ~ numberofdrugs, family=poisson)
> plot(test, which=5)

```

Does anybody know, how to get rid of the red dashed line legend which says cook's distance?

Answer: 
I don't know if you can get rid of that line but you can simply create that plot manually. Afterwards you can add all the legends you want or don't want.
E.g. take a look at the `boot` package.

In your case, this will do your plot

```
plot(y = glm.diag(test)$rp, x = glm.diag(test)$h)

```

As far as i know there is a `glm.diag.plots` function as well. Take a look at their help pages.
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](https://stackoverflow.com/questions/2458013/what-ways-are-there-to-edit-a-function-in-r) 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)

```