标签:
1 data<-read.csv("附件3.csv") 2 x<-data[,1] 3 y<-data[,2] 4 windows() 5 barplot(y,col=2,main="所有车次平均客座率",cex.axis=1, 6 xlab="车次",ylab="客座率") 7 grid(nx=NA,ny=10,lwd=2) 8 axis(1,at=x,labels=x)
1 x_name<-c("1","2","3","4","5","6","7","8","9","10","11","12","1601", 2 "1602","1603") 3 4 data<-read.csv("车次.csv") 5 data[,1]=as.character(data[,1]) 6 plot(data[,2]/1000,type="o", col="tan",axes=FALSE,ann=FALSE,ylim=c(0,800)) # 绘制蓝色折线图, 7 axis(1, at=1:15, lab=x_name)# 8 title(main="不同车次客流量", col.main="red", font.main=4) # 增添标题,红色,粗斜体 9 axis(2) 10 grid(nx=NA,ny=10,lwd=2) 11 box() 12 title(xlab="月份", col.lab=rgb(0,0.5,0)) # 添加x轴标题 13 title(ylab="客流量/(千人)", col.lab=rgb(0,0.5,0)) # 添加y轴标题 14 lines(data[,3]/1000, type="o", pch=22, lty=1, col="Brown") 15 lines(data[,4]/1000, type="o", pch=22, lty=1, col="DarkSlateGray") 16 lines(data[,5]/1000, type="o", pch=22, lty=1, col="grey31") 17 lines(data[,5]/1000, type="o", pch=22, lty=1, col="DarkCyan") 18 lines(data[,6]/1000, type="o", pch=22, lty=1, col="DarkMagenta") 19 lines(data[,7]/1000, type="o", pch=22, lty=1, col="DarkRed") 20 lines(data[,8]/1000, type="o", pch=22, lty=1, col="PeachPuff1") 21 lines(data[,9]/1000, type="o", pch=22, lty=1, col="Orange") 22 lines(data[,10]/1000, type="o", pch=22, lty=1, col="Gold") 23 lines(data[,11]/1000, type="o", pch=22, lty=1, col="Firebrick") 24 lines(data[,12]/1000, type="o", pch=22, lty=1, col="ForestGreen") 25 lines(data[,13]/1000, type="o", pch=22, lty=1, col="DarkGreen") 26 lines(data[,14]/1000, type="o", pch=22, lty=1, col="MediumBlue") 27 tuli<-c("ZD111-01","ZD111-02","ZD311","ZD326","ZD192","ZD022","ZD250","ZD062","ZD120","ZD121","ZD143","ZD370","ZD190-02","ZD190-01") 28 legend("bottomright",legend=tuli, cex=0.8, col=c("Brown","DarkSlateGray","grey31" ,"DarkCyan", 29 "DarkMagenta","DarkRed", "PeachPuff1","Orange" ,"Gold","Firebrick","ForestGreen", "DarkGreen", 30 "MediumBlue"),lty=1) 31 # legend(),1,g_range[2]表示图例左上角的坐标;c("cars","trucks")标签,cex=0.8字体的放大倍数
1 plot(data[,7]/1000,type="o", col="tan",axes=FALSE,ann=FALSE,ylim=c(0,150)) # 绘制蓝色折线图, 2 axis(1, at=1:15, lab=x_name) 3 axis(1, at=1:15, lab=x_name)# 4 title(main="不同车次客流量", col.main="red", font.main=4) # 增添标题,红色,粗斜体 5 axis(2) 6 grid(nx=NA,ny=10,lwd=2) 7 box() 8 title(xlab="月份", col.lab=rgb(0,0.5,0)) # 添加x轴标题 9 title(ylab="客流量/(千人)", col.lab=rgb(0,0.5,0)) # 添加y轴标题 10 lines(data[,8]/1000, type="o", pch=22, lty=1, col="PeachPuff1") 11 lines(data[,9]/1000, type="o", pch=22, lty=1, col="Orange") 12 lines(data[,10]/1000, type="o", pch=22, lty=1, col="Gold") 13 lines(data[,11]/1000, type="o", pch=22, lty=1, col="Firebrick") 14 lines(data[,12]/1000, type="o", pch=22, lty=1, col="ForestGreen") 15 lines(data[,13]/1000, type="o", pch=22, lty=1, col="DarkGreen") 16 #lines(data[,14]/1000, type="o", pch=22, lty=1, col="MediumBlue") 17 tuli<-c("ZD250","ZD062","ZD120","ZD121","ZD143","ZD370","ZD190-01") 18 legend("bottomright",legend=tuli, cex=0.8, col=c("PeachPuff1","Orange" ,"Gold","Firebrick","ForestGreen", "DarkGreen", 19 "MediumBlue"),lty=1)
标签:
原文地址:http://www.cnblogs.com/chance88/p/5790671.html