DATAGURU专业数据分析网站
2013.03.23
数据分析、展现与R语言 第9周
DATAGURU专业数据分析网站
2013.03.23
线图
使用cityrain.csv数据
rain<-read.csv("cityrain.csv")
plot(rain$Tokyo,type="b",lwd=2,
xaxt="n",ylim=c(0,300),col="black",
xlab="Month",ylab="Rainfall (mm)",
main="Monthly Rainfall in major cities")
axis(1,at=1:length(rain$Month),labels=rain$Month)
lines(rain$Berlin,col="red",type="b",lwd=2)
lines(rain$NewYork,col="orange",type="b",lwd=2)
lines(rain$London,col="purple",type="b",lwd=2)
legend("topright",legend=c("Tokyo","Berlin","New York","London"),
lty=1,lwd=2,pch=21,col=c("black","red","orange","purple"),
ncol=2,bty="n",cex=0.8,
text.col=c("black","red","orange","purple"),
inset=0.01)
3
DATAGURU专业数据分析网站
2013.03.23
线图
4
DATAGURU专业数据分析网站
2013.03.23
给线图增加legend(图例)
legend(1,300,legend=c("Tokyo","B
erlin","New York","London"),
lty=1,lwd=2,pch=21,col=c("black"
,"red","orange","purple"),
horiz=TRUE,bty="n",bg="yellow",
cex=1,
text.col=c("black","red","orange","
purple"))
5