我有一个数据集,其中包含 53 条鱼的深度位置的平均值和最小值最大值,跨越 3 个月。我想制作一个ggplot
包括所有鱼(可能会有点混乱),将平均值和最小值最大值显示为阴影“平均值周围的变化” - 这些值不是 SD 值。
这就是我希望它看起来的样子
(在这篇文章中找到;使用 ggplot 绘制时间序列中多个变量的平均值)
我已经尝试替换和摆弄该示例中使用的代码(当然还有其他代码),并且我创建了一个“不错”的情节(不是我现在所追求的) - 但不能发布图像,但我使用的代码如下;
ggplot(data=Dybde_mnd_gjsn, aes(x=MONTH, y=MEAN, colour=factor(ID))) +
geom_line()
只有几个变量:
names(Dybde_mnd_gjsn)
[1] "MONTH" "MEAN" "ID"
我现在将用于绘制振幅的数据集还有几个变量:
names(Dybde_amplitude)
[1] "MONTH" "DAY" "MEAN" "MIN" "MAX" "ID"
这是我要使用的数据片段
> dput(Dybde_amplitude)
structure(list(MONTH = c(5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
9L, 9L, 9L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L), DAY = c(7L,
8L, 9L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L,
28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L,
26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L,
28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L), MEAN = c(9.540647, 9.288714, 8.432471, 7.377365,
6.76296, 6.276494, 12.972529, 18.019079, 6.788923, 6.215657,
8.04514, 5.633161, 8.073261, 6.390555, 7.356341, 6.908082, 7.733372,
7.702988, 8.027043, 7.180671, 8.35001, 8.806448, 9.189368, 11.639917,
11.278741, 8.360776, 10.257245, 10.149662, 12.750096, 8.278289,
5.989309, 12.213945, 8.508868, 12.648187, 12.878193, 14.39192,
7.623049, 11.484679, 10.60802, 8.295495, 8.845541, 8.139116,
9.62127, 10.122368, 9.006005, 10.353516, 12.176356, 8.705348,
8.43072, 13.068286, 15.310207, 15.686594, 14.840801, 11.393752,
12.468137, 17.784591, 8.108516, 14.655444, 10.515425, 12.431097,
9.919435, 10.394816, 11.558687, 15.752784, 15.442462, 12.866537,
13.900521, 11.482066, 6.671224, 8.342884, 16.114621, 16.629631,
8.660017, 14.224467, 15.533569, 12.41233, 5.960347, 9.871627,
7.989248, 8.348769, 10.795695, 18.17083, 15.11693, 14.552147,
11.116431, 13.92426, 15.067066, 16.546982, 12.09092, 15.489066,
16.386997, 16.369983, 16.666472, 16.439537, 14.961976, 8.400368,
9.243826, 8.860606, 15.482827, 5.891674, 12.889285, 8.104939,
17.531697, 10.702164, 13.657768, 14.816514, 10.093246, 9.122293,
4.729045, 5.458503, 5.705868, 12.748805, 14.904001, 17.692, 6.036507,
6.629023, 6.006198, 6.620014, 6.388301, 4.964946, 5.70888, 6.731503,
4.177703, 5.707092, 5.419896, 5.743811, 6.914309, 8.771285, 10.280664,
8.882466, 10.232784, 10.717011, 10.578657, 11.56234, 12.180956,
11.682375, 10.127121, 11.493758, 10.475167, 9.530382, 7.278434,
11.031396, 7.510209, 11.197544, 11.953527, 11.764005, 10.732215,
6.84638, 11.731543, 11.593536, 7.999654, 9.747014, 8.357976,
7.9729, 14.120155, 11.902921, 10.197552, 8.073362, 10.317106,
13.507428, 14.653348, 10.425436, 13.372142, 14.139852, 8.292127,
13.026231, 10.412969, 15.822424, 16.974569, 18.421219, 14.874954,
15.19774, 16.192414, 13.456357, 18.018939, 13.06192, 8.639087,
12.765785, 11.764159, 8.551737, 14.76467, 10.406063, 11.606126,
14.361956, 12.14953, 11.489708, 15.935027, 17.127559, 16.522154,
10.894316, 13.134836, 13.114416, 13.727499, 15.169832, 15.189013,
16.968254, 15.396868, 14.64583, 14.812744, 15.053284, 15.157046,
16.467487, 16.665042, 15.150461, 14.635215, 14.721557, 15.840516,
17.882953, 15.356118, 16.391199, 15.900671, 15.42199, 10.389486,
7.947174, 12.650666, 14.631651, 12.691862, 11.540124, 11.898669,
11.366367, 12.491286, 12.607952, 12.714351, 14.942454, 12.351443,
13.195234, 12.010512, 12.305635, 12.216722, 12.777485, 9.775835,
11.955268, 11.368552, 11.016467, 9.721845, 10.806302, 10.9171,
10.453463, 12.844585, 11.418213, 10.494833, 11.628353, 11.089386,
10.114644, 11.518541, 10.556667, 9.999429, 6.240064, 7.614508,
2.759079, 8.675967, 7.665187, 9.996974, 9.409778, 11.284177,
9.915669, 10.073183, 12.478693, 9.344805, 9.985623, 10.137344,
10.899548, 10.987574, 9.602739, 9.522853, 6.755497, 5.770355,
5.752236, 7.560061, 8.650949, 9.461071, 10.349785, 9.341064,
9.639314, 8.979398, 9.63129, 10.736764, 9.131154, 8.569252, 9.456744,
8.771311, 10.607428, 8.951906, 8.621349, 7.685053, 8.024678,
5.514734, 7.39701, 4.573696, 4.639201, 4.925964, 11.295734, 4.381326,
4.320309, 5.210907, 5.367718, 4.563952, 4.744356, 2.950165),
MIN = c(8.797308, 8.678333, 7.766875, 6.853333, 5.61875,
5.353125, 11.882128, 17.313191, 5.425833, 5.225, 6.31375,
4.785, 6.648333, 5.077917, 5.8925, 5.627083, 6.487917, 6.67875,
7.119792, 5.867872, 7.636512, 7.513556, 7.923125, 10.500426,
10.328667, 6.31617, 8.871875, 8.767872, 11.512979, 6.486809,
4.961702, 10.671042, 7.100851, 11.570208, 11.542766, 12.385238,
6.311087, 10.100208, 9.577805, 7.345227, 7.866042, 7.204,
8.253023, 8.769375, 7.894167, 9.400851, 11.269744, 7.655417,
6.812979, 11.394375, 13.8175, 14.294375, 13.165208, 9.943191,
11.276444, 16.884167, 7.246889, 12.704375, 8.956889, 11.251277,
8.311458, 8.62383, 10.030833, 14.564375, 14.605417, 11.158542,
12.42125, 10.294, 5.315208, 7.044792, 14.696458, 15.389167,
7.3975, 13.421489, 14.955319, 11.108478, 4.849167, 8.50125,
6.776957, 7.408723, 9.500625, 17.558511, 14.387708, 13.864167,
9.728542, 13.374, 14.145833, 15.628542, 10.460213, 14.234565,
16.26875, 16.195833, 16.179167, 16.118182, 14.107083, 7.67125,
9.060638, 7.975833, 13.734687, 4.4, 11.070444, 6.305641,
16.709574, 9.93, 12.559792, 14.010417, 9.10587, 7.900345,
4.048, 4.371304, 5.315833, 11.510833, 13.698125, 16.65375,
5.158542, 5.748667, 4.957083, 5.524583, 5.204375, 4.235,
4.8025, 5.868913, 3.491915, 5.030435, 4.711458, 4.958958,
5.879348, 7.601087, 8.915, 7.87275, 9.358261, 9.74625, 9.087708,
10.858723, 11.538333, 10.801489, 9.237333, 10.321042, 9.425217,
8.394444, 6.378182, 9.80766, 6.812667, 10.236667, 10.202917,
10.403333, 9.350238, 6.253902, 10.940233, 10.502766, 7.186667,
8.949773, 7.541395, 7.541395, 13.215435, 11.171064, 9.319302,
7.197021, 9.524043, 12.797292, 13.830208, 9.306809, 12.304043,
12.910976, 7.762778, 12.136429, 9.322826, 15.460625, 16.665333,
18.2125, 13.856087, 13.862979, 15.556136, 12.174118, 16.92,
11.778857, 7.635263, 11.865909, 10.958444, 7.853404, 14.153095,
9.717955, 10.932955, 13.724667, 10.874146, 10.57119, 15.215714,
16.384186, 15.662791, 9.91617, 12.607442, 12.325217, 12.901163,
14.532326, 14.454091, 16.248222, 14.838511, 14.012708, 14.251489,
14.418125, 14.396522, 16.020625, 15.897447, 14.54413, 13.964375,
14.271064, 15.27625, 17.429787, 14.618444, 15.641489, 15.257174,
14.84186, 9.652708, 7.102667, 12.118261, 14.130513, 12.154,
10.940698, 11.418913, 10.768043, 11.788085, 12.017556, 12.192326,
14.272895, 11.660417, 12.43619, 11.482766, 11.761304, 11.775,
12.280435, 9.125217, 11.464348, 10.741522, 10.584783, 9.086957,
10.062667, 10.385652, 9.785, 12.26, 10.839268, 9.808864,
10.80025, 10.574419, 9.469583, 10.794634, 9.949149, 9.406458,
4.863617, 6.528125, 2.577143, 7.9805, 7.077083, 9.406585,
8.903556, 10.933, 9.384146, 9.681778, 11.786, 8.873478, 9.341333,
9.362, 10.171282, 10.353, 9.095435, 8.736087, 5.785208, 4.785152,
5.163871, 6.848333, 7.645862, 9.119714, 9.895143, 8.720227,
9.019048, 8.169231, 8.652553, 9.837872, 8.077708, 7.354043,
8.591556, 8.024894, 9.41766, 7.989535, 7.86973, 6.921111,
6.793939, 5.034815, 6.788718, 4.00119, 3.939778, 4.139545,
10.178667, 3.931915, 3.692174, 4.627273, 4.967568, 4.021395,
4.380652, 2.825263), MAX = c(10.215385, 9.747708, 8.920625,
8.013958, 8.067917, 7.41, 14.122128, 18.531277, 8.23375,
7.503125, 9.537083, 6.659375, 9.591458, 7.88625, 8.799167,
8.335417, 8.806875, 8.7025, 8.793125, 8.531702, 8.967209,
10.017556, 10.391042, 12.829574, 12.124667, 10.097447, 11.530625,
11.344043, 14.207872, 9.877021, 7.166809, 14.081875, 10.238723,
13.89375, 14.41383, 16.892143, 8.935217, 12.958542, 11.717805,
9.260455, 9.698958, 9.1995, 10.746744, 11.263542, 10.07375,
11.502553, 13.095641, 9.9025, 10.048511, 14.837708, 16.728125,
17.283333, 16.538333, 12.96383, 13.912889, 18.56875, 8.991333,
16.5925, 11.898222, 13.544681, 11.173958, 12.095106, 12.826667,
16.841667, 16.102083, 14.120833, 15.475, 12.647111, 8.1475,
10.014792, 17.6, 17.7, 10.006875, 14.974468, 16.187234, 13.607174,
7.147083, 11.132917, 9.376739, 9.333404, 11.991875, 18.652979,
15.874375, 15.365417, 12.478958, 14.561333, 15.710417, 17.25625,
13.652128, 16.800435, 16.4375, 16.50625, 17.383333, 16.870455,
15.819167, 8.9865, 9.429149, 9.826667, 17.449375, 7.644615,
14.726, 10.080769, 18.468511, 11.542292, 14.902708, 15.435,
10.948261, 10.493103, 5.148, 6.656957, 6.126458, 14.110417,
16.245833, 18.708542, 6.928542, 7.402889, 7.362292, 7.847917,
7.513542, 5.682292, 7.056667, 7.581087, 4.830213, 6.350435,
6.203125, 6.69625, 7.854565, 9.83, 12.218043, 9.91375, 11.210217,
11.911667, 11.977917, 12.235319, 12.869792, 12.59, 10.904,
12.784583, 11.599565, 10.868889, 8.172955, 12.354894, 8.29,
12.584792, 13.69875, 13.4375, 12.084762, 7.459268, 12.525814,
12.690638, 8.770889, 10.471364, 9.085349, 8.343256, 14.877391,
12.579574, 10.923953, 9.053191, 11.291277, 14.24, 15.647083,
11.66, 14.248723, 15.392927, 8.849722, 13.746905, 11.335,
16.13875, 17.231333, 18.5625, 16.004348, 16.694894, 16.927727,
14.602941, 19.270526, 14.102857, 9.673158, 13.643409, 12.648222,
9.327447, 15.280238, 11.120227, 12.355682, 14.967556, 13.422927,
12.263095, 16.472381, 17.768372, 17.498605, 11.689787, 13.640233,
13.728696, 14.696744, 15.730698, 15.930455, 17.747111, 15.903404,
15.326667, 15.362979, 15.710417, 15.831957, 17.023333, 17.588085,
15.782609, 15.255833, 15.112766, 16.508958, 18.248936, 16.036222,
17.105532, 16.641739, 15.978372, 11.263333, 8.832889, 13.246957,
15.210769, 13.252444, 12.264651, 12.448696, 11.922174, 13.205106,
13.237333, 13.215349, 15.572368, 12.949792, 13.973571, 12.448936,
12.824348, 12.726304, 13.20587, 10.500435, 12.617826, 12.051087,
11.623043, 10.586739, 11.522, 11.592826, 11.18, 13.480811,
12.013171, 11.237727, 12.2745, 11.579767, 10.610417, 12.045854,
11.186596, 10.53375, 7.959787, 8.633437, 2.954286, 9.378,
8.316875, 10.447073, 9.791556, 11.7455, 10.434878, 10.571111,
13.021429, 9.997391, 10.452, 10.915111, 11.569231, 11.545,
10.148478, 10.29087, 8.039375, 6.98697, 6.281935, 8.181429,
9.577241, 9.891429, 11.002857, 9.821136, 10.195714, 9.894359,
10.444681, 11.646596, 10.203125, 9.886383, 10.184444, 9.619149,
11.618511, 10.00093, 9.375405, 8.419333, 9.280606, 6.762222,
7.907179, 5.254048, 5.393556, 5.644773, 12.823778, 5.107447,
5.060652, 5.784318, 5.773514, 5.135814, 5.240652, 3.08),
ID = c(7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L, 7288L,
7288L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L, 7293L,
7293L, 7293L, 7293L)), .Names = c("MONTH", "DAY", "MEAN",
"MIN", "MAX", "ID"), class = "data.frame", row.names = c(NA,
-299L))
这可以理解吗?!我是 R 和 ggplot 的新手,所以这篇文章可能看起来有点傻。
非常感谢您对此事的任何帮助!另外,这merge
与数据集有什么关系?重要吗??