r - line type legend not showing and background in not correct -
i have plot:
dates = as.numeric(as.date(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 ))+ geom_hline(aes(yintercept = 6,linetype ="dashed"),color = "green") + geom_hline(aes(yintercept = 7,linetype ="dashed"),color = "blue") + geom_vline(aes(xintercept = as.numeric(as.date("2017-03-13") ),linetype ="dashed"),color = "yellow") + geom_vline(aes(xintercept = as.numeric(as.date("2017-03-14") ),linetype ="dashed"),color = "yellow") + #geom_vline(aes(xintercept = "2017-03-13",linetype ="dashed"),color = "red")+ scale_color_manual(name="group", labels = c(a="a",b= "b",c = "c"), values = c(a="green",b="red" , c = "orange" ) ) +scale_linetype_manual("linetype",labels=c("y1", "y2","datelines","datelines"),values=c("solid","solid","solid","solid") ) + theme( panel.background = element_rect(fill = "black", colour = "black"), legend.key = element_rect(colour = "black", fill = "black") )+ guides( size = guide_legend(override.aes = list(color = "red")), linetype = guide_legend(override.aes = list(fill = "white")) ) questions:
(1) using scale_linetype_manual expecting legend called "linetype" 3 types of lines: y1 , y2 , datelines (both horizontal lines have same label , color) see y1 legend. how can see 3 legends 1 y1, y2 , datelines?
so i'm trying "linetype" legend green dashed line called y1, blue dashed line called y2 , yellow line called datelines white background
(2) i'd backgound of "linetype" legend white used
linetype = guide_legend(override.aes = list(fill = "white")) but background still shows white.
Comments
Post a Comment