Ask on the ggplot mailing list?
Normally you use melted data (see the reshape2 package) and let the scales
feature build the legend for you.
---
Jeff NewmillerThe . . Go Live...
DCN:
Map year to an aesthetic and let ggplot do it for you:
df2010$year <- 2010
df2011$year <- 2011
df2012$year <- 2012
dfAll <- rbind(df2010, df2011, df2010)
ggplot(dfAll, aes(x=Price, y=percenCapacity, color=year) +
scale_x_log10()
Best,
Ista
On Mon, Dec 17, 2012 at 6:03 PM, jcrosbie wrote:
>
> H
How to I go about adding a legend to the following plot?
ggplot() + geom_line(aes(x=df2010$Price,y=df2010$percentCapacity), colour =
"red")
+ geom_line(aes(x=df2011$Price,y=df2011$percentCapacity), colour = "green")
+geom_line(aes(x=df2012$Price,y=df2012$percentCapacity), colour = "blue")
+sc
3 matches
Mail list logo