R添加图例

时间:2018-07-31 23:06:02

标签: r plot

Sunspots: Moving Averages  好, 这是我试图用来创建图例和结果图像的代码:

plot(C$Ymd,C$Spots,type="l",ylab="Sunspots",xlab="Year",col="black",lwd="1")
lines(C$Ymd,C$ma30,type="l", col="red")
lines(C$Ymd,C$ma90,type="l", col="green")
grid(col="black")
legend(2000,9.5,c("ma30","ma90"), # puts text in the legend
     lty=c(1,1), # gives the legend appropriate symbols (lines)
     lwd=c(2.5,2.5),col=c("red","green")) # gives the legend lines the correct color and width                                                 

0 个答案:

没有答案