R建模20160820

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) 

2.windows

 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字體的放大倍數

3.字體

 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)

 


 

 

 

數據spa

 

2016-04-223d

1.rest

 1 data<-read.csv("d.csv")
 2 data2<-t(data)
 3 plot(data2[2:19,1],type="o",col="tan",axes=FALSE,ann=FALSE,ylim=c(0,1800)) # 繪製藍色折線圖,
 4 x_name<-c('5-6點','6-7點','7-8點','8-9點','9-10點','10-11點',
 5           '11-12點','12-13點','13-14點','14-15點','15-16點','16-17點','17-18點',
 6           '18-19點','19-20點','20-21點','21-22點','22-23點')
 7 axis(1, at=1:18, 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(data2[2:19,2], type="o", pch=22, lty=1, col="Brown")
15 lines(data2[2:19,3], type="o", pch=22, lty=1, col="DarkSlateGray")
16 lines(data2[2:19,4], type="o", pch=22, lty=1, col="grey31")
17 lines(data2[2:19,5], type="o", pch=22, lty=1, col="DarkCyan")
18 lines(data2[2:19,6], type="o", pch=22, lty=1, col="DarkMagenta")
19 lines(data2[2:19,7], type="o", pch=22, lty=1, col="DarkRed")
20 lines(data2[2:19,8], type="o", pch=22, lty=1, col="PeachPuff1")
21 lines(data2[2:19,9], type="o", pch=22, lty=1, col="Orange")
22 lines(data2[2:19,10], type="o", pch=22, lty=1, col="Gold")
23 
24 data3<-read.csv("e.csv")
25 data4<-read.csv("f.csv")
26 data3_a=t(data3)
27 data4_a=t(data4)
28 data5_a<-data4_a+data3_a

2.code

 1 layout(matrix(c(1,2,3,2),nr=2))
 2 data_up<-read.csv("up.csv")
 3 data2_up<-t(data_up)
 4 up<-plot(data2_up[2:19,1],type="o",col="tan",axes=FALSE,ann=FALSE,ylim=c(0,1800)) # 繪製藍色折線圖,
 5 x_name<-c('5-6點','6-7點','7-8點','8-9點','9-10點','10-11點',
 6           '11-12點','12-13點','13-14點','14-15點','15-16點','16-17點','17-18點',
 7           '18-19點','19-20點','20-21點','21-22點','22-23點')
 8 axis(1, at=1:18, lab=x_name)#
 9 title(main="不一樣時刻車站上車客流量", col.main="red", font.main=4) # 增添標題,紅色,粗斜體
10 axis(2)
11 grid(nx=NA,ny=10,lwd=2)
12 box()
13 title(xlab="時間", col.lab=rgb(0,0.5,0)) # 添加x軸標題
14 title(ylab="客流量/(人)", col.lab=rgb(0,0.5,0)) # 添加y軸標題
15 lines(data2_up[2:19,2], type="o", pch=22, lty=1, col="Brown")
16 lines(data2_up[2:19,3], type="o", pch=22, lty=1, col="DarkSlateGray")
17 lines(data2_up[2:19,4], type="o", pch=22, lty=1, col="grey31")
18 lines(data2_up[2:19,5], type="o", pch=22, lty=1, col="DarkCyan")
19 lines(data2_up[2:19,6], type="o", pch=22, lty=1, col="DarkMagenta")
20 lines(data2_up[2:19,7], type="o", pch=22, lty=1, col="DarkRed")
21 lines(data2_up[2:19,8], type="o", pch=22, lty=1, col="PeachPuff1")
22 lines(data2_up[2:19,9], type="o", pch=22, lty=1, col="Orange")
23 lines(data2_up[2:19,10], type="o", pch=22, lty=1, col="Gold")
24 tuli<-c("ZD111-01","ZD326","ZD250","ZD062","ZD190-01","ZD190-02","ZD192",
25         "ZD111-03","ZD022","ZD311")
26 legend("bottomright",legend=tuli, cex=0.8, col=c("Brown","DarkSlateGray","grey31" ,"DarkCyan",
27                                                  "DarkMagenta","DarkRed", "PeachPuff1","Orange" ,"Gold"),lty=1)
28 # legend(),1,g_range[2]表示圖例左上角的座標;c("cars","trucks")標籤,cex=0.8字體的放大倍數
29 
30 
31 data_down<-read.csv("down.csv")
32 data2_down<-t(data_down)
33 down<-plot(data2_down[2:19,1],type="o",col="tan",axes=FALSE,ann=FALSE,ylim=c(0,1800)) # 繪製藍色折線圖,
34 x_name<-c('5-6點','6-7點','7-8點','8-9點','9-10點','10-11點',
35           '11-12點','12-13點','13-14點','14-15點','15-16點','16-17點','17-18點',
36           '18-19點','19-20點','20-21點','21-22點','22-23點')
37 axis(1, at=1:18, lab=x_name)#
38 title(main="不一樣時刻車站下車客流量", col.main="red", font.main=4) # 增添標題,紅色,粗斜體
39 axis(2)
40 grid(nx=NA,ny=10,lwd=2)
41 box()
42 title(xlab="時間", col.lab=rgb(0,0.5,0)) # 添加x軸標題
43 title(ylab="客流量/(人)", col.lab=rgb(0,0.5,0)) # 添加y軸標題
44 lines(data2_down[2:19,2], type="o", pch=22, lty=1, col="Brown")
45 lines(data2_down[2:19,3], type="o", pch=22, lty=1, col="DarkSlateGray")
46 lines(data2_down[2:19,4], type="o", pch=22, lty=1, col="grey31")
47 lines(data2_down[2:19,5], type="o", pch=22, lty=1, col="DarkCyan")
48 lines(data2_down[2:19,6], type="o", pch=22, lty=1, col="DarkMagenta")
49 lines(data2_down[2:19,7], type="o", pch=22, lty=1, col="DarkRed")
50 lines(data2_down[2:19,8], type="o", pch=22, lty=1, col="PeachPuff1")
51 lines(data2_down[2:19,9], type="o", pch=22, lty=1, col="Orange")
52 lines(data2_down[2:19,10], type="o", pch=22, lty=1, col="Gold")
53 tuli<-c("ZD111-01","ZD326","ZD250","ZD062","ZD190-01","ZD190-02","ZD192",
54         "ZD111-03","ZD022","ZD311")
55 legend("bottomright",legend=tuli, cex=0.8, col=c("Brown","DarkSlateGray","grey31" ,"DarkCyan",
56                                                  "DarkMagenta","DarkRed", "PeachPuff1","Orange" ,"Gold"),lty=1)
57 # legend(),1,g_range[2]表示圖例左上角的座標;c("cars","trucks")標籤,cex=0.8字體的放大倍數
58 
59 
60 
61 he<-plot(data5_a[2:19,1],type="o",col="tan",axes=FALSE,ann=FALSE,ylim=c(0,2500)) # 繪製藍色折線圖,
62 x_name<-c('5-6點','6-7點','7-8點','8-9點','9-10點','10-11點',
63           '11-12點','12-13點','13-14點','14-15點','15-16點','16-17點','17-18點',
64           '18-19點','19-20點','20-21點','21-22點','22-23點')
65 axis(1, at=1:18, lab=x_name)#
66 title(main="不一樣時刻車站客流量", col.main="red", font.main=4) # 增添標題,紅色,粗斜體
67 axis(2)
68 grid(nx=NA,ny=10,lwd=2)
69 box()
70 title(xlab="時間", col.lab=rgb(0,0.5,0)) # 添加x軸標題
71 title(ylab="客流量/(人)", col.lab=rgb(0,0.5,0)) # 添加y軸標題
72 lines(data5_a[2:19,2], type="o", pch=22, lty=1, col="Brown")
73 lines(data5_a[2:19,3], type="o", pch=22, lty=1, col="DarkSlateGray")
74 lines(data5_a[2:19,4], type="o", pch=22, lty=1, col="grey31")
75 lines(data5_a[2:19,5], type="o", pch=22, lty=1, col="DarkCyan")
76 lines(data5_a[2:19,6], type="o", pch=22, lty=1, col="DarkMagenta")
77 lines(data5_a[2:19,7], type="o", pch=22, lty=1, col="DarkRed")
78 lines(data5_a[2:19,8], type="o", pch=22, lty=1, col="PeachPuff1")
79 lines(data5_a[2:19,9], type="o", pch=22, lty=1, col="Orange")
80 lines(data5_a[2:19,10], type="o", pch=22, lty=1, col="Gold")
81 
82 tuli<-c("ZD111-01","ZD326","ZD250","ZD062","ZD190-01","ZD190-02","ZD192",
83 "ZD111-03","ZD022","ZD311")
84 legend("bottomright",legend=tuli, cex=0.8, col=c("Brown","DarkSlateGray","grey31" ,"DarkCyan",
85                                                  "DarkMagenta","DarkRed", "PeachPuff1","Orange" ,"Gold"),lty=1)
86 # legend(),1,g_range[2]表示圖例左上角的座標;c("cars","trucks")標籤,cex=0.8字體的放大倍數
87       

3.圖形blog

相關文章
相關標籤/搜索