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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -