legend()函数
> plot(rain$Tokyo,type="l",col="red", + ylim=c(0,300), + main="Monthly Rainfall in major cities", + xlab="Month of Year", + ylab="Rainfall (mm)", + lwd=2) > lines(rain$NewYork,type="l",col="blue",lwd=2) > lines(rain$London,type="l",col="green",lwd=2) > lines(rain$Berlin,type="l",col="orange",lwd=2)
1.第一种样式
> legend("topright", #图例位置为右上角 + legend=c("Tokyo","NewYork","London","Berlin"), #图例内容 + col=c("red","blue","green","orange"), #图例颜色 + lty=1,lwd=2) #图例大小
2.第二种样式
> legend("top", #图例位置为上方 + legend=c("Tokyo","NewYork","London","Berlin"), + ncol=4, + cex=0.8, + bty="n", + col=c("red","blue","green","orange"), + lty=1,lwd=2)
请发表评论