We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm finding it difficult to merge a scale_linetype_manual with the other guides.
scale_linetype_manual
library("ggplot2") df <- structure(list(year = c(1990, 2000, 2010, 2020, 2030, 2040), variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "Something", class = "factor"), value = c(4, 5, 6, 7, 8, 9), category = structure(c(1L, 1L, 1L, 2L, 2L, 2L), .Label = c("Observed", "Projected"), class = "factor"), category2 = structure(c(NA, NA, 1L, 1L, NA, NA), .Label = "Transition", class = "factor")), row.names = c(NA, 6L), class = "data.frame") df.sub <- na.omit(df) # First attempt: ggplot(data = df, aes(x = year, y = value)) + geom_point(aes(group = category, colour = category, shape = category), size = 4) + geom_line(aes(group = category, colour = category), size = 1) + geom_line(data = df.sub, aes(linetype = ""), group = 1, colour = "black", size = 1) + scale_linetype_manual(name = "category", values = "dotted", labels = "Transition")
# Second attempt: ggplot(data = df, aes(x = year, y = value)) + geom_point(aes(group = category, colour = category, shape = category), size = 4) + geom_line(aes(group = category, colour = category, linetype = ""), size = 1) + geom_line(data = df.sub, aes(linetype = category2), group = 1, colour = "black", size = 1) + scale_linetype_manual(name = "category", values = c("solid", "dashed", "solid"), labels = c("Observed", "Transition", "Projected"))
Created on 2021-05-07 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered:
Maybe related to SO questions https://stackoverflow.com/questions/50293125/r-change-ggplot-legend-names-with-scale-linetype-manual, https://stackoverflow.com/questions/68540054/how-to-modify-the-linetype-of-the-legend-of-hline-in-ggplot2 and issue #4479 ?
Sorry, something went wrong.
You are right that merging manual legends are pretty difficult. The key is to make sure that all scales have the exact same title and breaks....
Down the line it would be nice to have a more flexible guide system but this is a pretty big effort unrelated to this particular issue
No branches or pull requests
I'm finding it difficult to merge a
scale_linetype_manual
with the other guides.scale_linetype_manual
(I don't see any at this time)Created on 2021-05-07 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered: