r - multiple legends setting legend key circle color -
i have plot:
dates = c("2017-03-13","2017-03-13","2017-03-14","2017-03-14","2017-03-14") value = c(5,6,7,8,9) group = c("a","b","a","b","c") size = c(10,20,30,40,50) data =data.frame(dates= dates, value = value, group = group, size = size) ggplot(data, aes(x = dates, y = value, group = group)) + geom_point(aes (color = as.factor(group), size= size ))+ scale_color_manual(name="group", labels = c(a="a",b= "b",c = "c"), values = c(a="green",b="red" , c = "orange" ) ) + theme( panel.background = element_rect(fill = "black", colour = "black"), legend.key = element_rect(colour = "black", fill = "black") ) there 2 issues:
(1) in size legend circle black , background black. how make color of circle red can see circles on black background?
you need override.aes in guide_legend change aesthetic settings in legend without changing plot.
+ guides(size = guide_legend(override.aes = list(color = "red")))
Comments
Post a Comment