-1
將線路類型在傳說我策劃了以下情節:如何通過ggplot
通過使用代碼:
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))
沒有人知道如何改變相應的行傳說中的類型?
你可能會發現更容易'reshape' /'melt'您的數據,然後映射結果變量的'colour'和'linetype'美學。然後,相應的圖例將自動生成。 – user20650
請參閱http://stackoverflow.com/questions/3777174/plotting-two-variables-as-lines-using-ggplot2-on-the-same-graph#3777592,http://stackoverflow.com/questions/23420961/繪製-多線從 - 一個數據幀與 - GGPLOT2 – user20650