Closed gogonzo closed 2 years ago
Closing the issue - I made a mistake by putting show.legend = TRUE
- everything works as expected. You saved me!
library(ggplot2)
library(ggnewscale)
gg <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) +
geom_line(aes(group=Species, color = Species)) +
facet_grid(.~Species)
hor <- data.frame(yintercept = c(4, 5), horizontal = factor(c("h1", "h2")))
vert <- data.frame(xintercept = 6, vertical = factor("v1"))
gg +
new_scale_color() +
geom_hline(aes(yintercept = yintercept, colour = horizontal), data = hor, linetype = "solid") +
scale_color_manual(name="Horizontal lines", values = c("red","darkred")) +
new_scale_color() +
geom_vline(aes(xintercept = xintercept, colour = vertical), data = vert,linetype = "solid") +
scale_color_manual(name="Vertical lines", values = "green")
I love when issues close themselves 🤣️. Glad everything's fixed now.
Hi, I've discovered your package recently and it helped in recent issue of mine. I'm building a plot which combines some basic line and arbitrary straight lines. Each of the line should be described in the legend with appropriate color/type/orientation. It works excellent when the lines differs only by colour, otherwise it got little mixed.
I have tried to fix it though the guides but it doesn't help
Do you have a plan to separate the other line-attributes?
Regards, DK