单帧中的多个折线图

时间:2017-10-21 21:59:57

标签: r

我有一个想要显示的放电数据;观察到模拟。数据如下;

Time    observed    simulated
Jan-86  0.105   0.1597
Feb-86  0.0933  0.1259
Mar-86  3.5336  0.41
Apr-86  8.8999  2.494
May-86  5.2431  1.767
Jun-86  0.9747  1.96
Jul-86  0.079   1.98
Aug-86  0.0154  1.729
Sep-86  0.0053  1.419
Oct-86  0.0135  1.121
Nov-86  0.0235  0.8664
Dec-86  0.017   0.658
Jan-87  0.017   0.4925
Feb-87  0.017   0.3855
Mar-87  3.3483  1.089
Apr-87  3.3156  1.704
May-87  0.5563  1.327
Jun-87  0.2565  1.166
Jul-87  0.0446  1.012
Aug-87  0.0096  0.8278
Sep-87  0.0007  0.6567
Oct-87  0.0018  0.5083
Nov-87  0.0139  0.3892
Dec-87  0.0087  0.2953
Jan-88  0.0025  0.2196
Feb-88  0.0017  0.1641
Mar-88  0.0099  0.3858
Apr-88  1.6217  3.929
May-88  0.3398  0.5156
Jun-88  0.762   0.5537
Jul-88  0.0242  0.4985
Aug-88  0.0002  0.4125
Sep-88  0.0003  0.4027
Oct-88  0   0.2918
Nov-88  0   0.2388
Dec-88  0.0005  0.2024
Jan-89  0.0003  0.147
Feb-89  0.0004  0.1157
Mar-89  0.0006  0.3886
Apr-89  6.5433  10.92
May-89  0.8047  1.685
Jun-89  0.7968  1.486
Jul-89  0.0836  1.407
Aug-89  0.0024  1.22
Sep-89  0.0001  0.9965
Oct-89  0   0.7846
Nov-89  0.0005  0.6097
Dec-89  0   0.4636
Jan-90  0   0.3469
Feb-90  0   0.271
Mar-90  0.2724  0.9063
Apr-90  0.3768  2.902
May-90  0.0776  0.5038
Jun-90  0.1327  0.5622
Jul-90  0.0636  0.5068
Aug-90  0.0005  0.4169
Sep-90  0   0.3328
Oct-90  0   0.2611
Nov-90  0   0.2016
Dec-90  0   0.1549
Jan-91  0   0.116
Feb-91  0.0004  0.0904
Mar-91  0.0024  0.0709
Apr-91  0.0056  0.3813
May-91  0.1312  0.6567
Jun-91  0.1033  0.6053
Jul-91  1.1491  0.6226
Aug-91  0.0957  0.5423
Sep-91  0.01    0.4529
Oct-91  0.009   0.374
Nov-91  0.0436  0.3132
Dec-91  0.0629  0.2344
Jan-92  0.0238  0.1775
Feb-92  0.0125  0.1378
Mar-92  2.4242  3.399
Apr-92  2.9119  4.284
May-92  1.0843  1.854
Jun-92  0.1473  1.7
Jul-92  0.3467  1.451
Aug-92  0.0143  1.182
Sep-92  0.0193  2.272
Oct-92  0.035   1.332
Nov-92  0.0132  1.181
Dec-92  0.0353  0.9716
Jan-93  0.0213  0.7097
Feb-93  0.0196  0.5596
Mar-93  0.2553  5.669
Apr-93  3.4093  4.912
May-93  0.4553  1.575
Jun-93  1.4621  1.56
Jul-93  2.7732  2.622
Aug-93  7.4911  1.587
Sep-93  7.7134  1.381
Oct-93  0.4065  1.133
Nov-93  0.3042  0.9257
Dec-93  0.1669  0.7514
Jan-94  0.0756  0.5657
Feb-94  0.0317  0.4464
Mar-94  1.3576  3.802
Apr-94  1.5093  4.446
May-94  0.8696  1.246
Jun-94  0.3097  1.426
Jul-94  4.1223  1.66
Aug-94  0.6915  0.7939
Sep-94  3.9228  0.6434
Oct-94  1.5528  0.5081
Nov-94  3.0506  0.3907
Dec-94  0.6294  0.3053
Jan-95  0.2484  0.2327
Feb-95  0.1053  0.1842
Mar-95  9.4852  7.073
Apr-95  3.8737  3.122
May-95  3.0692  1.754
Jun-95  0.3433  1.386
Jul-95  2.6554  1.297
Aug-95  0.3252  0.9797
Sep-95  0.2854  0.7803
Oct-95  0.2667  0.6097
Nov-95  0.1444  0.4692
Dec-95  0.1098  0.355
Jan-96  0.0696  0.265
Feb-96  0.0399  0.4352
Mar-96  0.0419  0.2793
Apr-96  16.2771 17.33
May-96  25.3653 21.04
Jun-96  0.4064  4.901
Jul-96  0.3028  3.886
Aug-96  0.097   3.1
Sep-96  0.0325  2.51
Oct-96  0.0949  2.009
Nov-96  0.2763  1.614
Dec-96  0.1307  1.252
Jan-97  0.0778  0.9253
Feb-97  0.0661  0.7211
Mar-97  0.0703  0.7519
Apr-97  27.3434 21.65
May-97  4.2895  7.989
Jun-97  0.4939  3.661
Jul-97  6.7193  3.92
Aug-97  0.1174  2.802
Sep-97  0.0858  2.229
Oct-97  2.0501  1.789
Nov-97  0.891   1.644
Dec-97  0.3561  1.288
Jan-98  0.133   0.94
Feb-98  0.8482  2.56
Mar-98  7.2317  6.613
Apr-98  3.7604  4.181
May-98  3.039   2.323
Jun-98  5.3291  2.492
Jul-98  5.6387  2.607
Aug-98  0.1308  1.943
Sep-98  0.0937  1.647
Oct-98  1.4565  1.641
Nov-98  0.7778  1.563
Dec-98  0.5755  1.692
Jan-99  0.0573  1.65
Feb-99  0.0783  1.489
Mar-99  2.3554  7.688
Apr-99  25.3018 18.41
May-99  8.7571  5.154
Jun-99  14.8313 3.564
Jul-99  4.7535  2.423
Aug-99  3.6622  1.898
Sep-99  5.0639  1.524
Oct-99  0.9153  1.186
Nov-99  0.4436  0.905
Dec-99  0.181   0.6864
Jan-00  0.1015  0.5129
Feb-00  1.9763  0.3953
Mar-00  2.5832  0.3083
Apr-00  3.6585  0.2388
May-00  0.9701  0.182
Jun-00  7.1744  0.1605
Jul-00  1.7145  0.1494
Aug-00  0.6677  0.1364
Sep-00  0.1858  0.1195
Oct-00  1.1442  0.0997
Nov-00  15.1503 0.6839
Dec-00  0.5526  0.4275
01-Jan  0.182   0.6061
01-Feb  0.1582  0.5254
01-Mar  0.7527  0.437
01-Apr  18.8305 21
01-May  4.0794  2.765
01-Jun  1.7906  5.399
01-Jul  0.2344  2.615
01-Aug  2.8721  1.896
01-Sep  0.108   1.555
01-Oct  0.0896  1.237
01-Nov  0.6865  0.9588
01-Dec  0.1609  0.7329
02-Jan  0.0987  0.5496
02-Feb  0.081   0.4299
02-Mar  0.0671  0.4125
02-Apr  1.9161  5.189
02-May  2.8088  2.423
02-Jun  18.2132 2.137
02-Jul  2.881   2.783
02-Aug  0.676   1.102
02-Sep  1.309   0.892
02-Oct  0.1844  0.7183
02-Nov  0.1415  0.56
02-Dec  0.0781  0.4277
03-Jan  0.0897  0.3211
03-Feb  0.0191  0.2515
03-Mar  1.1978  2.32
03-Apr  1.4536  2.175
03-May  1.2194  0.9472
03-Jun  2.2049  0.7456
03-Jul  0.1934  0.6395
03-Aug  0.0362  0.5237
03-Sep  0.0047  0.4738
03-Oct  0.0338  0.3477
03-Nov  0.1166  0.2821
03-Dec  0.0301  0.2319
04-Jan  0.0151  0.1851
04-Feb  0.0218  0.1462
04-Mar  2.9284  3.967
04-Apr  5.113   8.21
04-May  14.4488 6.077
04-Jun  8.7876  4.92
04-Jul  0.7572  2.781
04-Aug  0.3186  2.023
04-Sep  1.7134  1.648
04-Oct  0.834   1.385
04-Nov  1.5215  1.571
04-Dec  0.1535  1.175
05-Jan  0.0515  0.8762
05-Feb  0.0535  0.7016
05-Mar  0.5916  2.954
05-Apr  10.2761 12.22
05-May  4.3927  3.95
05-Jun  12.6566 8.826
05-Jul  13.6267 4.855
05-Aug  11.4682 3.241
05-Sep  1.2082  2.454
05-Oct  1.1875  1.986
05-Nov  1.5555  1.566
05-Dec  0.3229  1.294
06-Jan  0.1832  1.055
06-Feb  0.112   0.885
06-Mar  0.3341  3.006
06-Apr  24.8525 19.75
06-May  6.2187  4.442
06-Jun  0.3634  2.697
06-Jul  0.0534  1.889
06-Aug  0.0439  1.571
06-Sep  0.02    1.261
06-Oct  0.0418  0.9836
06-Nov  0.0612  0.7535
06-Dec  0.0747  0.5717
07-Jan  0.0644  0.43
07-Feb  0.0339  0.3319
07-Mar  2.8046  2.675
07-Apr  2.7156  3.412
07-May  0.5788  2.576
07-Jun  8.5705  9.888
07-Jul  1.3929  2.897
07-Aug  0.1146  1.758
07-Sep  0.0374  1.486
07-Oct  0.1637  1.338
07-Nov  0.1599  1.2
07-Dec  0.1165  0.9649
08-Jan  0.054   0.7372
08-Feb  0.024   0.5469
08-Mar  0.04    0.6989
08-Apr  2.3773  9.219
08-May  1.3455  3.223
08-Jun  1.4375  4.011
08-Jul  0.531   2.341
08-Aug  0.0512  1.618
08-Sep  0.0902  1.377
08-Oct  2.8219  1.115
08-Nov  4.7166  0.9028
08-Dec  0.3393  0.8564
09-Jan  0.1303  0.6376
09-Feb  0.1594  0.7089
09-Mar  10.3111 5.402
09-Apr  14.466  14.64
09-May  6.0214  13.73
09-Jun  5.4491  6.086
09-Jul  7.4774  4.059
09-Aug  0.4845  2.885
09-Sep  0.1321  2.208
09-Oct  0.0935  1.755
09-Nov  0.1702  1.367
09-Dec  0.0786  1.183
10-Jan  0.049   1.461
10-Feb  0.0502  0.8349
10-Mar  9.9809  7.328
10-Apr  2.1785  5.341
10-May  5.54    9.544
10-Jun  6.5798  10.35
10-Jul  1.4304  5.972
10-Aug  0.3424  3.768
10-Sep  8.7223  3.844
10-Oct  5.7656  4.88
10-Nov  3.7897  4.978
10-Dec  0.5271  3.289

我尝试了以下代码来显示数据

require(xts)
data <- read.csv('./flowout13.csv')
dd1<-data.frame(data[2:3])
dd1<-ts(dd1,frequency = 12,start = 1986)
plot(as.xts(dd1),major.format="%y-%m")
title(main="Calibrated observed and simulated discharge",xlab="Time",ylab="discharge in mm")
legend("topleft", inset=0.10, title="Discharge",
       c("observed","simulated","r2=0.8", "NSE=0.60"), fill=terrain.colors(2), horiz=FALSE)

并且图表没有显示图形的实际颜色。我想要观察到的黑色线条和模拟的红色但它显示不同。我不希望r2和NSE是任何颜色它们只是值,我从不同的计算中添加。我还想在日期之下更改xlab的位置。请帮忙。我在r studio工作。

enter image description here

1 个答案:

答案 0 :(得分:1)

这是你正在寻找的吗?

plot(as.xts(dd1), major.format="%y-%m", col = terrain.colors(2))

enter image description here