-1

I have plotted the following plot:

enter image description here

By using the code:

ggplot(decadevalue, aes(decade,group=1))+ 
geom_line(aes(y=decadevalue[,1],colour="black"),size=1.5,linetype = "dashed")+
geom_line(aes(y=decadevalue[,2],colour="#E69F00"),size=1.5,linetype = "twodash")+
geom_line(aes(y=decadevalue[,3],colour="#56B4E9"),size=1.5)+
geom_line(aes(y=decadevalue[,4],colour="#009E73"),size=1.5)+
geom_line(aes(y=decadevalue[,5],colour="#F0E442"),size=1.5)+
geom_line(aes(y=decadevalue[,6],colour="#0072B2"),size=1.5)+
geom_line(aes(y=decadevalue[,7],colour="#D55E00"),size=1.5)+
geom_line(aes(y=decadevalue[,8],colour="#CC79A7"),size=1.5)+
geom_line(aes(y=decadevalue[,9],colour="#000000"),size=1.5)+
geom_line(aes(y=decadevalue[,10],colour="#CC6666"),size=1.5,linetype = "dotted")+
ggtitle("Plot of Percentage of Motivations by Decade")+
xlab("Decade")+ ylab("Percentage")+
scale_colour_discrete(name="",labels=c(MI[9],MI[6],MI[4],MI[3],MI[10],MI[8],MI[7],MI[2],MI[5],MI[1]))+
scale_linetype_discrete(limits = c(rep("solid", 4),"dotted",rep("solid",2),"twodash","solid","dashed"))+
theme(axis.text.x = element_text(angle = 45, hjust = 1))

Does Anyone know how to change the corresponding line types in legend?

steveb
  • 5,382
  • 2
  • 27
  • 36
DA_PA
  • 231
  • 1
  • 4
  • 10
  • You will probably find it easier to `reshape` / `melt` your data, and then map resulting variables to the `colour`, and `linetype` aesthetics. Then the appropriate legend will be auto-generated. – user20650 Apr 02 '16 at 20:21
  • see http://stackoverflow.com/questions/3777174/plotting-two-variables-as-lines-using-ggplot2-on-the-same-graph#3777592, http://stackoverflow.com/questions/23420961/plotting-multiple-lines-from-a-data-frame-with-ggplot2 – user20650 Apr 02 '16 at 20:24

1 Answers1

0

You can make use of scale_linetype_manual

scale_linetype_manual(values=c(1,1,1,1,2,3,2,3))+ 
...
...
Sowmya S. Manian
  • 3,723
  • 3
  • 18
  • 30