• 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.

     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)


    数据

    2016-04-22

    1.

     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.

     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.图形

    本性的苏醒,往往在遭遇真实之后。
  • 相关阅读:
    如何用伪类画出一个三角形
    关于昨天遇到题目的一点随笔
    opacity与rgba
    选择框脚本_移动/重排选项 P435
    文字等宽
    CSS3风骚渐变
    表单序列化 P436
    选择框脚本_添加/删除选项 P434
    选择框脚本_用事件选中选项,获取选中项信息 P432
    文本框组脚本_自动切换焦点“例如加区号和分机号的电话号码文本框组” P426
  • 原文地址:https://www.cnblogs.com/chance88/p/5790671.html
Copyright © 2020-2023  润新知