r - Changing line colors with ggplot() -


i don't use ggplot2 much, today thought i'd give go on graphs. can't figure out how manually control colors in geom_line()

i'm sure i'm overlooking simple, here's test code:

x <- c(1:20, 1:20) variable <- c(rep("y1", 20), rep("y2", 20) ) value <- c(rnorm(20), rnorm(20,.5) )  df <- data.frame(x, variable, value )  d <- ggplot(df, aes(x=x, y=value, group=variable, colour=variable ) ) +              geom_line(size=2) d 

which gives me expected output:

enter image description here

i thought had simple like:

d +  scale_fill_manual(values=c("#cc6666", "#9999cc")) 

but changes nothing. missing?

color , fill separate aesthetics. since want modify color need use corresponding scale:

d + scale_color_manual(values=c("#cc6666", "#9999cc")) 

is want.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -