I was looking at The right way to plot multiple y values as separate lines with ggplot2 to get the proper syntax to have multiple Y's for the same X. I was able to do so correctly (in this case I actually used the format of the submitter, as I only wanted one extra Y so it was just as easy).
My trouble comes in that I want to set the two lines to different colors, and I want to specify the color (ie. color = I('blue')
), but doing so results in the error
Don't know how to automatically pick scale for object of type AsIs. Defaulting to continuous
Error: Discrete value supplied to continuous scale
My code as is follows:
ggplot(aes(x = age), data = by_age) +
geom_line(aes(y = friend_mean, color = "blue")) +
geom_line(aes(y = friend_med))
This does result in one line being colored, but not in the color specified, and it applies "blue"
as a label.
So how would I go about setting a color in ggplot, using defined, static colors (red, blue, green, etc.)?
Thanks!