r - Delete one aes from legend generated from two layes sharing common aes name -
r - Delete one aes from legend generated from two layes sharing common aes name -
my question want overlay scatter plot on top of line plot , these 2 plots' color alter 1 variable. want maintain legend 1 color. if utilize scale_colour_discrete(guide = "none")
both of them gone.
a reproducible illustration is:
library(reshape2) iris2 <- melt(iris, id.var = "species") ggplot(iris2, aes(x = variable, y = value, grouping = species)) + geom_point(aes(color = ifelse(value < 3, "type1", "type2"))) + geom_line(aes(color = species))
i want show legend 'species' rather type.
setting show_guide=false
in geom_point layer,
ggplot(iris2, aes(x = variable, y = value, grouping = species)) + geom_point(aes(color = ifelse(value < 3, "type1", "type2")), show_guide=false) + geom_line(aes(color = species)) + scale_colour_discrete("species", breaks=levels(iris2$species))
r ggplot2
Comments
Post a Comment