I want to adding a legend in my graph.
but It's very difficult to me.
so please help me..
library(ggplot2)
library(scales)
library(grid)
library(gcookbook)
data<-read.csv("maxmin.csv")
attach(data)
head(data)
str(data)
to<-ggplot(data,aes(x=obs,y=toaverage)) + geom_ribbon(aes(ymin=tomin,ymax=tomax),alpah=0.9,fill="grey50") + geom_line(colour="black")+ labs(x = "", y = "")+ scale_y_continuous(breaks=seq(0,70,10))+ expand_limits(max(data$tomax),y=c(0,70))
to<-to + theme(axis.text.x=element_blank())+ geom_ribbon(aes(ymin=tomax25,ymax=tomax75),alpah=0.9,fill="grey30") + theme(axis.ticks.x=element_blank())
to<- to + theme(line = element_blank())+ theme(text = element_text(size=15))
to<-to + geom_line(aes(y=toaverage),colour="black")
this is work.
and I want to adding a legend at bottom
to<-to+ scale_colour_manual(value=c("black","grey50",grey"30"), breaks=c("toaverage","tomax","tomax25"), labels=c("average","(max,min)","(25%,75%)"))+ theme(legend.position="bottom")
But this is not work..
(tomax25 and tomax75 is quantile of max and min)
actually I want to adding a average line and grey50 and grey 30 are colour box.
How i can solve this problem.?
Thanks in advinance.