why is a second legend not included in my ggplot?

My suggestion would be to manually populate the mapping of geom_abline(), and then cut the data so that it matches the number of lines you’re drawing. Illustrated below with an inbuilt dataset.

library(ggplot2)

ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  geom_abline(aes(linetype = c("m1", "m3"),
                  slope = c(0.5, 0.75),
                  intercept = c(0, 0.5)),
              data = iris[1:2,])

Created on 2020-11-06 by the reprex package (v0.3.0)

For your use case you’d have to substute slope = c(0.5, 0.75) by slope = c(fixef(mod2b)[2], fixef(mod2d)[2]), etc.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top