添加点到框图

时间:2017-10-24 10:18:36

标签: r plot simulation boxplot

我想将80组模拟数据与df_dis和观察数据df_obs进行比较。

> df_obs
    Year Measurement(mm/5min)
V1  1997                 13.8
V2  1998                  5.6
V3  1999                  8.7
V4  2000                  2.2
V5  2001                  5.0
V6  2002                  5.6
V7  2003                  6.3
V8  2004                  8.0
V9  2005                 10.0
V10 2006                  4.1


> df_dis
        1997      1998      1999     2000      2001      2002      2003      2004      2005      2006
1  11.867536  2.997962  6.561550 2.747768  5.900000  6.650000  4.031792  6.654992  4.800841  4.800000
2  23.000000  3.975762  5.391287 2.105289  9.600000  8.118585  4.704294 15.412469  7.200000  5.569136
3  10.307710 12.446996  4.059950 3.582672  8.850000 10.868867  6.877682 10.150000  7.018794  8.200000
4  10.747655  6.664877  5.451646 2.200000 10.800000  4.879799 15.853224  4.026445  6.668597  5.537502
5   9.908165  4.700000  5.592828 1.991793  5.924517  5.664091  8.098545  5.984483 11.616766  2.450000
6  13.007778  4.162451  9.544901 2.526081  4.993840  5.360516 17.607850  7.784428  6.834983  4.800000
7  35.287519  7.343955 10.093886 2.366667  3.553820  8.600000  4.336879  3.109716  4.685052  9.663994
8  16.535472  5.800000  5.174187 4.400000  6.408823  6.130276  7.138689  4.849496  3.290624  3.500000
9   8.030428  4.237314  4.114529 3.800000  3.804399  3.927062 11.734724  7.160396  4.501750 11.369553
10  6.878482  6.400000  6.045036 1.447210  4.369025  3.944151  6.140711  6.142415  4.393665  4.628941
11  9.971474  6.668979  5.803412 2.215701  5.038590  4.288869  6.201564  7.641028  7.021023  4.446041
12  7.622905  3.669006  9.721541 2.700000  5.803399  6.650000  3.960955  4.569611  3.866065  4.107408
13  7.650000  4.468356 21.685232 2.154913  9.204739 11.504138  6.496002 17.420063 11.500000  3.182818
14 11.457681  3.600000  5.169739 1.654013  4.950000 13.314681  4.900000 10.500000  5.181120  4.705728
15 10.726826  3.848087  7.500000 2.159726  9.035845  4.463510  4.445909  2.700000  5.892559  6.163731
16 13.613139  4.852336  6.670162 2.100000  5.329876  4.150000  6.671311  8.895903  5.835336  9.300000
17  7.650000  6.954779  4.378949 2.500000  8.834307  4.083644  7.702367  5.400000  4.836455  4.496888
18 12.670690  4.729430  6.474932 1.618055  6.256126  4.420383  4.325609  5.852377  9.752342  5.347470
19 13.733704  6.003298 10.148355 1.835558  5.900000  5.000000  4.065643  5.605338  4.832926  4.808189
20 10.877573  4.583852  5.211081 2.772953 11.163938  6.211545  8.466667  7.284090  9.990617  4.490608
21 17.592204  3.703285 18.998844 3.000000  4.022228  7.568902  3.754317  7.158259  4.808672  4.564047
22 23.721926  7.500000  5.468419 2.384397  3.623313  4.234803  3.428251  5.082590  3.823373  3.152586
23  7.806926  6.385768  9.534758 2.200000  7.467894  8.072397  8.729327  4.949999  4.597851  6.324855
24  7.859289  7.750000  4.900175 1.862400  5.000000 14.200000  5.425819  3.500000  6.647975  3.470626
25 11.769267  5.928119  4.925015 3.453749  7.500000  8.044495  7.063833  5.130110  7.699427  4.600000
26 14.990159  6.536461  4.466667 4.925153  6.000000  4.584685  4.771231  7.877949  6.100000  4.800000
27 26.385344  3.400000  6.899422 4.300000  5.798142  5.299272  8.774232  4.846432  3.948207  7.731065
28  7.408517  5.166667  4.988909 1.891832  7.645180  5.321938 11.588035  3.635404  7.666667  7.700000
29  6.054789  7.500000  4.290585 2.200000  5.000000  3.531657  7.888664  5.632526  3.638497  5.866520
30  8.879151  3.323299  4.057739 3.550000  5.900000  4.969340  3.849961  6.203902 14.299657  8.200000
31  7.640779  4.769838  4.108584 1.765295  8.147742  3.866667  7.948936  5.250000  6.024620  5.893952
32 17.100000  6.906096 12.900000 2.200000  8.909376 10.711517  9.738119  5.400000  7.666667  7.200000
33  8.114287  5.000000 10.098495 3.970349  5.156315  5.800000  8.466667  5.500000  6.743269  3.931859
34  9.592879  7.750000  5.599132 1.928337  4.040401  3.201808  8.466667  8.771074  6.336100 14.400000
35 15.333333  7.302768  4.647098 2.138497  6.847052  6.779115  6.512436  5.554527  2.823096  3.506642
36 14.236894  7.500000  6.358530 2.200000  5.468317  3.850000 19.487377  3.300000  4.277918  4.800000
37  9.270922  4.635945 10.851531 3.550000  6.182234  6.419109  7.324375  5.400000  6.603740 11.321240
38  6.666877  2.658040 12.352862 3.223733  5.219637  6.110787  4.735401  8.947780  7.666667  7.593935
39  8.101113  6.990208 10.428106 2.400000  4.827160 11.324250  6.699802  4.524573  3.512940  3.850000
40  9.594549  4.667580  4.849753 2.379600  7.459532  3.936348  6.414417  7.407172  3.850000  3.619882
41 20.620800  4.331381  8.208012 2.147492  5.858324  6.936505  7.978956  7.834758  3.652256  4.353305
42 15.333333  4.754273  6.433912 1.589988  9.900000  6.017443  5.000000  7.933329  4.700000  4.700000
43 13.424019  4.100000  7.198340 3.437020  4.720535 10.281223  7.472005  3.528851  8.166800  3.326935
44 13.917612  4.844640  7.500000 2.366667  6.341884 11.600000  5.513130  5.834020  5.000000  6.582977
45  6.787986  3.598405  7.986405 2.200000 11.082184  4.965501  6.177231  6.793439  9.019647  6.376973
46  9.372343  6.400000  5.511734 2.601031  9.304379  6.715259  7.131833  4.707099  5.444170  2.572549
47 16.019822  4.281006  4.764002 3.405690  4.075916  7.100000  6.117486  5.424290  9.314490  4.171691
48 18.370531  6.189574  3.959383 1.900000 11.239349  4.716339 12.433048  4.046864 11.500000  6.600000
49 46.000000  6.581131  5.194206 2.800000  4.466667 11.649814  4.787661  5.544467  4.600000  5.277514
50  8.176290 11.688619  4.036034 1.487373 10.004906  6.572176  3.478050  8.900000  4.595165  4.231876
51 23.000000  7.471908  7.767062 3.823786 17.700000  4.733333  8.631051  5.055963  3.846241  3.751469
52  8.818760  3.520552  6.046130 2.358780  3.634652  7.100000  6.145960  4.450000  5.084726  3.872850
53  7.060434  5.379426  5.076971 2.104185  5.559818  4.324275  4.674747  3.078808  4.266531  6.700000
54  8.956666  2.677810  7.033278 3.447914  4.838196  6.842076  4.967049  4.288682  6.558591  3.969899
55  6.900000  6.521603  4.616673 2.200000  9.787084  5.800000  4.957555  4.967365  3.609429 10.928744
56  9.406496  6.530785 16.281940 1.700000  4.868558  4.500422  5.803293  6.848926  6.404908  3.863699
57 10.262732  4.768241  7.115803 4.148872  3.632829  4.400000  5.864975  4.954014  3.850000 13.200000
58  8.847913  9.200000  5.489541 1.335609  4.466667  3.544398  5.500000  4.950648  6.801970  3.715422
59 17.731915  4.413660  6.854924 4.200000  8.481887  6.600000  8.466667  4.837656  9.990496  6.452207
60  9.552820  4.207636  5.231991 7.100000 11.992556  6.464110  8.466667  4.206009  6.470158  5.200000
61  6.577734  3.882290  4.549373 3.576548  5.900000 10.904683  6.362839  3.976825  6.332559  6.895395
62 14.940222  5.776195 18.927924 3.238345  3.765740  8.632122  6.322808  5.250000  7.789110  7.700000
63 12.652988  4.030859  5.429949 1.684622  3.986361  4.276517 11.196542  3.924914  4.958475  8.363014
64 11.021169  6.400000  9.702341 1.849220  5.888817  4.807270  6.208735  8.921690  6.051399  4.310970
65  9.359067  4.600000  6.700000 2.370614  5.900000  3.713599  4.897343  5.645729 11.554155 11.218221
66  8.300000  7.750000  5.688564 2.617694  5.408627 10.900000  9.577002 13.071179  4.965686  4.504782
67  8.326502  5.271627  6.766261 1.868733  4.929720  6.302340  6.592735  7.486963  9.413102  2.751875
68 14.764402  6.097843  4.698832 3.005814  6.819835  4.463528  5.226827  5.074886  4.231347  5.648472
69 15.300000  5.090108  7.174838 2.000000 15.000000  5.446018  5.121835  3.619711  8.079609  4.487291
70 11.073171  4.962797  4.421677 2.150000  4.825012  6.384028  7.792403  3.601920  4.444032  7.200000
71 13.654803  4.712003  4.185373 1.814623  4.293027  6.026786  7.285100  6.766667  4.826704  3.595945
72 10.571143  3.658383  6.427868 3.290796  4.842849  5.450000  4.975071  6.641049  6.180490  2.693947
73 26.333599  6.946639  7.279733 2.500000 17.700000  5.800000  7.478573  3.773272  5.380978  4.400000
74 12.124302  5.614320  6.230680 2.006076  4.099169  5.369948  4.956912  5.156135  4.099502  4.220052
75 15.333333  3.925801  6.700000 2.026701  4.612262  7.198059  4.912072  4.228732  5.412175  9.368507
76  7.011089  9.240360  9.638279 2.366667  4.911345  3.656532  9.000000  6.590379  5.267070  3.100000
77 12.524717  6.781750  7.926700 1.600000  5.934553  6.657764  7.233498  6.167878  5.866904  3.128598
78  8.732311  4.200000  4.884092 2.487054  5.900000  6.390073  5.061877  6.100000  3.700000  5.813896
79 20.334151  5.634527  7.157759 3.452066  7.536877  7.500000 10.820713  6.418468  4.000000  5.858031
80 14.884259  4.610309  8.386756 2.120737  4.391419  8.132990  5.050685  4.351414 17.978707  4.530237

我想将df_dis显示为boxplot,将df_obs显示为同一图中的点图。我只管理了两个独立的地块 点图和箱形图:

enter image description here

enter image description here

如何将模拟数据显示为黑框图,并将观测数据显示为红色点,并在x-Year和y-Measurement(mm / 5min)的图表中显示为红点?

1 个答案:

答案 0 :(得分:0)

我假设每年只有一个boxplot

然后,我会在boxplot()之后使用

points(1997:2006, df_obs$Measurement(mm/5min))