在ggplot中绘图时,dbRDA绘图箭头矢量消失

brc7rcf0  于 2023-07-31  发布在  其他
关注(0)|答案(1)|浏览(137)

我第一次做一个基于距离的RDA图,我对结构不太熟悉。我有一个相当大的数据集,我在下面细分了一部分。

> dput(pc)
structure(list(Chlorophyll = c(1.457, 2.458, 1.89, 1.028, 1.202, 
0.981, 0.814, 1.45, 1.213, 0.154, 0.133, 0.115, 0.061, 0.023, 
0.02, 0.022, 0.028, 0.013, 7.703, 8.149, 7.85, 9.216, 9.372, 
8.863, 8.767, 9.354, 8.143, 3.389, 1.794186047, 1.81, 0.923, 
1.085, 0.622, 1.05, 0.908, 0.605, 0.11, 0.143, 0.13, 0.048, 0.036, 
0.054, 0.031, 0.019, 0.026, 8.111, 8.026, 8.191, 8.372, 8.796, 
7.149, 3.756, 2.459, 3.7), Temp = c(0.12, 0.12, 0.12, 0.12, 0.12, 
0.12, 0.12, 0.12, 0.12, 30.83, 30.83, 30.83, 30.83, 30.83, 30.83, 
30.83, 30.83, 30.83, 27.93, 27.93, 27.93, 27.93, 27.93, 27.93, 
27.93, 27.93, 27.93, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 
0.12, 0.12, 30.83, 30.83, 30.83, 30.83, 30.83, 30.83, 30.83, 
30.83, 30.83, 27.93, 27.93, 27.93, 27.93, 27.93, 27.93, 27.93, 
27.93, 27.93), Sal = c(23.38, 23.38, 23.38, 22.297, 22.297, 22.297, 
19.1649, 19.1649, 19.1649, 5.893208333, 5.893208333, 5.893208333, 
9.542607143, 9.542607143, 9.542607143, 8.57228, 8.57228, 8.57228, 
9.38747619, 9.38747619, 9.38747619, 11.44957692, 11.44957692, 
11.44957692, 9.093931034, 9.093931034, 9.093931034, 23.38, 23.38, 
23.38, 22.297, 22.297, 22.297, 19.1649, 19.1649, 19.1649, 5.893208333, 
5.893208333, 5.893208333, 9.542607143, 9.542607143, 9.542607143, 
8.57228, 8.57228, 8.57228, 9.38747619, 9.38747619, 9.38747619, 
11.44957692, 11.44957692, 11.44957692, 9.093931034, 9.093931034, 
9.093931034), Station = c("Stn01", "Stn01", "Stn01", "Stn01", 
"Stn01", "Stn01", "Stn01", "Stn01", "Stn01", "Stn01", "Stn01", 
"Stn01", "Stn01", "Stn01", "Stn01", "Stn01", "Stn01", "Stn01", 
"Stn11", "Stn11", "Stn11", "Stn11", "Stn11", "Stn11", "Stn11", 
"Stn11", "Stn11", "Stn11", "Stn11", "Stn11", "Stn11", "Stn11", 
"Stn11", "Stn11", "Stn11", "Stn11", "Stn20", "Stn20", "Stn20", 
"Stn20", "Stn20", "Stn20", "Stn20", "Stn20", "Stn20", "Stn20", 
"Stn20", "Stn20", "Stn20", "Stn20", "Stn20", "Stn20", "Stn20", 
"Stn20"), Hours = c(0L, 0L, 0L, 12L, 12L, 12L, 24L, 24L, 24L, 
0L, 0L, 0L, 12L, 12L, 12L, 24L, 24L, 24L, 0L, 0L, 0L, 12L, 12L, 
12L, 24L, 24L, 24L, 0L, 0L, 0L, 12L, 12L, 12L, 24L, 24L, 24L, 
0L, 0L, 0L, 12L, 12L, 12L, 24L, 24L, 24L, 0L, 0L, 0L, 12L, 12L, 
12L, 24L, 24L, 24L), Treatment = c("Diesel", "Diesel", "Diesel", 
"Diesel", "Diesel", "Diesel", "Diesel", "Diesel", "Diesel", "Heidrun", 
"Heidrun", "Heidrun", "Heidrun", "Heidrun", "Heidrun", "Heidrun", 
"Heidrun", "Heidrun", "Diesel", "Diesel", "Diesel", "Diesel", 
"Diesel", "Diesel", "Diesel", "Diesel", "Diesel", "Heidrun", 
"Heidrun", "Heidrun", "Heidrun", "Heidrun", "Heidrun", "Heidrun", 
"Heidrun", "Heidrun", "Diesel", "Diesel", "Diesel", "Diesel", 
"Diesel", "Diesel", "Diesel", "Diesel", "Diesel", "Heidrun", 
"Heidrun", "Heidrun", "Heidrun", "Heidrun", "Heidrun", "Heidrun", 
"Heidrun", "Heidrun"), ASV1 = c(0.007, 0, 0, 0, 0, 0, 0.005, 
0, 0.006, 0, 0.003, 0.004, 0.004, 0, 0, 0, 0, 0, 0.096, 0.094, 
0.088, 0.322, 0.266, 0.271, 0.94, 0.657, 0.792, 0.088, 0.082, 
0.11, 0.186, 0.31, 0.241, 0.428, 0.717, 0.718, 0.042, 0.032, 
0.075, 0.091, 0.033, 0.615, 0.671, 0.11, 0.144, 0.024, 0.038, 
0.041, 0.043, 0.028, 0.064, 0.077, 0.045, 0.147), ASV14 = c(0, 
0, 0, 0.005, 0, 0, 0.009, 0, 0, 0.008, 0, 0, 0, 0, 0, 0, 0, 0, 
0.404, 0.412, 0.408, 0.768, 0.836, 0.904, 0.856, 1.899, 1.526, 
0.409, 0.448, 0.553, 0.715, 0.77, 0.759, 0.726, 0.87, 0.755, 
0.266, 0.265, 0.329, 0.307, 0.362, 0.292, 0.251, 0.735, 0.737, 
0.199, 0.233, 0.644, 0.513, 0.331, 0.8, 0.634, 0.447, 0.68), 
    ASV4 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0.109, 0.056, 0.109, 0.207, 0.291, 0.252, 0.287, 0.23, 
    0.273, 0.123, 0.181, 0.166, 0.193, 0.27, 0.232, 0.13, 0.187, 
    0.198, 22.735, 20.565, 22.798, 25.258, 16.161, 15.316, 20.458, 
    19.074, 20.496, 18.417, 18.417, 20.008, 24.697, 18.131, 17.388, 
    13.913, 24.508, 18.437), ASV16 = c(0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.074, 0.082, 0, 0.121, 0.124, 
    0.132, 0.211, 0.217, 0.159, 0.098, 0.068, 0.097, 0.081, 0.093, 
    0.151, 0.086, 0.217, 0.129, 1.073, 0.836, 2.188, 1.759, 1.044, 
    4.985, 5.3, 1.842, 1.734, 1.523, 1.327, 1.086, 1.223, 1.139, 
    1.909, 2.279, 1.444, 2.011), ASV26 = c(0.175, 0.147, 0.133, 
    0.815, 0.947, 1.271, 2.673, 1.86, 2.641, 0.156, 0.128, 0.188, 
    1.448, 1.565, 1.398, 7.948, 5.597, 4.344, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0.024, 0, 0, 0.032, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ASV11 = c(8.924, 
    9.411, 10.039, 5.578, 6.433, 8.781, 8.147, 11.047, 8.307, 
    10.058, 11.989, 5.783, 7.928, 9.624, 9.718, 9.828, 10.211, 
    9.875, 0.52, 0.687, 0.71, 0.74, 0.801, 0.908, 0.994, 0.884, 
    1.102, 0.598, 0.528, 0.508, 0.982, 0.839, 0.911, 0.952, 0.899, 
    1.002, 0.041, 0.057, 0.038, 0.039, 0.058, 0.042, 0.066, 0.019, 
    0.038, 0.044, 0.059, 0.021, 0.028, 0.034, 0.025, 0.034, 0.028, 
    0.009), ASV20 = c(6.317, 6.75, 7.102, 6.196, 5.638, 6.557, 
    4.986, 6.655, 5.423, 6.669, 7.249, 6.129, 5.168, 6.293, 6.834, 
    5.132, 5.847, 6.289, 0.606, 0.522, 0.526, 0.171, 0.224, 0.244, 
    0.138, 0.245, 0.156, 0.692, 0.494, 0.511, 0.187, 0.095, 0.111, 
    0.179, 0.069, 0.06, 0.015, 0.018, 0.004, 0.005, 0.016, 0, 
    0.009, 0, 0, 0, 0.027, 0.006, 0, 0.018, 0, 0, 0, 0.007), 
    ASV34 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0.017, 0, 0.023, 0.032, 0.029, 0.034, 0.032, 0, 
    0.018, 0, 0.032, 0.024, 0.026, 0.026, 0.042, 0.067, 0.056, 
    0.919, 0.599, 1.094, 1.23, 1.077, 1.749, 1.963, 1.453, 1.353, 
    0.453, 0.675, 1.159, 0.988, 0.926, 2.021, 1.838, 0.83, 2.008
    ), ASV22 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0.027, 0.016, 0.027, 0.036, 0.085, 0.095, 0.064, 
    0.033, 0.095, 0.023, 0.044, 0.026, 0.037, 0.037, 0.043, 0.009, 
    0.036, 0.058, 6.453, 8.456, 5.719, 4.451, 4.007, 3.386, 3.564, 
    7.091, 8.964, 5.702, 3.989, 6.461, 8.256, 3.728, 5.847, 3.965, 
    8.686, 7.113), ASV49 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0.027, 0, 0.011, 0.027, 0, 0, 
    0.026, 0, 0.011, 0.018, 0, 0.014, 0.031, 0, 0.044, 0.054, 
    0.018, 0.039, 0.074, 0.054, 0.045, 0.655, 0.926, 0.02, 0.035, 
    0.017, 0.048, 0.028, 0.043, 0.064, 0.015, 0.032, 0.032, 0.026
    ), ASV3 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 2.498, 2.448, 2.737, 2.817, 2.498, 2.03, 2.333, 
    2.972, 2.158, 2.527, 2.124, 2.186, 2.777, 2.834, 2.747, 2.046, 
    2.277, 1.898, 2.945, 3.602, 4.455, 4.733, 4.487, 3.364, 3.264, 
    5.373, 4.641, 3.228, 3.7, 6.412, 5.719, 3.522, 6.755, 4.848, 
    4.438, 4.976), ASV5 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 1.73, 1.907, 1.893, 3.068, 2.993, 2.796, 
    3.412, 3.926, 3.789, 1.827, 1.393, 1.756, 2.921, 3.58, 3.478, 
    2.924, 3.614, 2.752, 7.245, 7.121, 7.652, 7.798, 6.822, 7.699, 
    7.812, 7.003, 7.719, 8.195, 8.768, 7.447, 6.309, 7.284, 6.224, 
    6.405, 6.938, 9.502), ASV6 = c(0.003, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05, 0.055, 0, 0.064, 
    0.138, 0, 0.088, 0, 0.017, 0.048, 0.03, 0.023, 0.068, 0.031, 
    0.065, 0.072, 0.039, 0.098, 0.085, 0.101, 0, 0.619, 0.982, 
    0.02, 0, 0.027, 0.038, 0.03, 0.032, 0.034, 0.021, 0.073, 
    0.028, 0), ASV21 = c(5.722, 6.321, 6.045, 5.352, 3.969, 5.728, 
    5.074, 5.918, 5.629, 6.141, 7.036, 4.947, 5.064, 6.364, 7.126, 
    7.013, 6.365, 6.16, 0.229, 0.19, 0.243, 0.048, 0.111, 0.07, 
    0.06, 0.052, 0.045, 0.308, 0.21, 0.282, 0.047, 0.023, 0.054, 
    0.047, 0.025, 0.025, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.011, 0.01, 
    0, 0, 0.012, 0, 0, 0, 0), ASV25 = c(0, 0.004, 0, 0, 0.005, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6.293, 6.924, 7.317, 
    4.524, 4.991, 5.362, 4.643, 5.169, 5.929, 6.41, 7.23, 6.147, 
    5.094, 6.87, 5.529, 7.668, 5.704, 5.072, 1.667, 1.666, 1.145, 
    0.974, 1.282, 1.277, 0.962, 0.502, 0.616, 1.799, 1.773, 1.056, 
    0.846, 1.601, 0.637, 0.596, 0.915, 0.901), ASV2 = c(0, 0.009, 
    0, 0, 0, 0.008, 0, 0, 0, 0.006, 0.003, 0, 0, 0, 0, 0, 0, 
    0, 4.997, 5.75, 5.824, 8.067, 9.432, 7.939, 9.147, 8.152, 
    9.012, 5.081, 4.151, 5.496, 7.102, 5.45, 7.292, 7.129, 5.872, 
    6.347, 5.169, 6.086, 4.868, 4.278, 6.192, 4.401, 3.745, 4.591, 
    5.171, 3.815, 5.712, 3.123, 4.026, 6.754, 3.625, 4.876, 5.948, 
    5.004), ASV78 = c(0.181, 0.22, 0.234, 0.185, 0.143, 0.261, 
    0.321, 0.233, 0.345, 0.2, 0.148, 0.204, 0.521, 0.559, 0.48, 
    1.379, 1.381, 1.214, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.027, 
    0, 0, 0, 0.038, 0.025, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0), ASV92 = c(0.115, 0.104, 0.081, 0.153, 
    0.135, 0.173, 0.313, 0.196, 0.277, 0.115, 0.147, 0.138, 0.27, 
    0.416, 0.326, 0.886, 1.127, 1.069, 0.029, 0.017, 0.019, 0.022, 
    0.015, 0.024, 0.03, 0.02, 0.013, 0.028, 0.017, 0, 0.038, 
    0.022, 0.032, 0, 0, 0.019, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0.006, 0, 0, 0, 0, 0, 0), ASV18 = c(0, 0, 0, 0, 0, 0, 
    0, 0, 0.003, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.408, 0.45, 0.367, 
    0.691, 0.633, 0.686, 0.703, 0.666, 0.656, 0.385, 0.398, 0.371, 
    0.602, 0.529, 0.609, 0.681, 0.781, 0.784, 3.545, 3.389, 4.617, 
    4.525, 4.93, 4.805, 4.086, 4.305, 4.287, 3.996, 4.576, 4.957, 
    3.899, 4.195, 5.636, 5.457, 3.591, 4.395), ASV57 = c(0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.033, 0, 
    0, 0.064, 0, 0, 0.102, 0, 0, 0.014, 0, 0.048, 0, 0, 0.036, 
    0.034, 0, 0.046, 0, 0, 0, 0, 0, 0, 0.072, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0), ASV36 = c(2.61, 2.493, 2.338, 2.733, 4.326, 
    3.046, 2.71, 2.456, 2.336, 2.197, 1.891, 3.385, 0.31, 0.318, 
    0.52, 0.062, 0.105, 0.103, 1.114, 0.712, 1.184, 0.807, 0.977, 
    0.65, 0.527, 0.382, 0.637, 0.978, 1.32, 1.651, 1.42, 1.661, 
    1.38, 1.344, 1.277, 1.557, 0.713, 0.671, 0.352, 0.302, 0.352, 
    0.176, 0.326, 0.415, 0.434, 0.56, 0.662, 0.372, 0.401, 0.478, 
    0.461, 0.456, 0.583, 0.663), ASV106 = c(0.068, 0.066, 0.055, 
    0.153, 0.175, 0.285, 0.509, 0.178, 0.434, 0.089, 0.064, 0.032, 
    0.382, 0.497, 0.225, 1.749, 1.11, 1.301, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ASV201 = c(0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.018, 0, 0, 
    0.031, 0, 0, 0.025, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ASV15 = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.705, 
    1.817, 1.624, 3.553, 2.902, 3.166, 3.962, 3.845, 3.715, 1.99, 
    1.86, 1.95, 2.947, 3.436, 3.207, 3.524, 4.138, 4.174, 1.789, 
    1.58, 2.363, 2.42, 2.374, 3.247, 2.538, 2.671, 2.595, 1.87, 
    2.19, 2.269, 1.81, 2.148, 3.196, 3.217, 1.911, 3.05), ASV88 = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.497, 
    0.514, 0.462, 0.677, 0.685, 0.671, 0.872, 0.69, 0.807, 0.482, 
    0.48, 0.429, 0.634, 0.705, 0.581, 0.674, 0.702, 0.743, 0.246, 
    0.199, 0.256, 0.264, 0.272, 0.442, 0.375, 0.208, 0.281, 0.348, 
    0.354, 0.173, 0.154, 0.283, 0.197, 0.232, 0.151, 0.208), 
    ASV42 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.008, 0, 0, 0.004, 
    0, 0, 0, 4.375, 5.041, 4.415, 4.129, 4.013, 4.272, 3.004, 
    2.354, 2.079, 4.168, 4.146, 3.828, 4.979, 4.203, 4.655, 3.863, 
    3.387, 3.688, 0.378, 0.523, 0.212, 0.188, 0.263, 0.228, 0.209, 
    0.109, 0.206, 0.407, 0.407, 0.187, 0.172, 0.278, 0.099, 0.166, 
    0.152, 0.145), ASV73 = c(0.752, 0.801, 0.413, 0.796, 0.91, 
    0.841, 1.039, 1.067, 1.078, 0.658, 0.684, 0.67, 1.757, 1.626, 
    0.86, 1.947, 2.075, 1.782, 0.008, 0.008, 0.016, 0.011, 0.015, 
    0.016, 0.015, 0.013, 0.002, 0.014, 0.01, 0.011, 0.02, 0.026, 
    0.017, 0.025, 0.01, 0.007, 0, 0, 0, 0, 0.006, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0), ASV46 = c(0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.042, 0.086, 0.054, 0.064, 
    0.079, 0.066, 0.077, 0.08, 0.066, 0.054, 0.076, 0.066, 0.074, 
    0.081, 0.075, 0.071, 0.088, 0.068, 1.979, 1.983, 1.994, 2.263, 
    2.804, 1.867, 1.997, 2.602, 2.527, 2.033, 2.543, 2.537, 2.627, 
    2.185, 2.586, 4.104, 1.837, 1.98), ASV1171 = c(0, 0, 0.009, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0.043, 0.011, 0.018, 0.015, 0, 0, 0, 0.014, 0, 0, 0.023, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 
    ASV145 = c(0.081, 0.073, 0.046, 0.071, 0.112, 0.144, 0.14, 
    0.145, 0.18, 0.076, 0.08, 0.087, 0.197, 0.196, 0.166, 0.556, 
    0.484, 0.493, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0), ASV32 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0.077, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0), ASV180 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0.027, 0, 0, 0.021, 0, 0.022, 0.02, 
    0, 0, 0, 0, 0, 0, 0, 0.02, 0.031, 0.011, 0.33, 0.17, 0.211, 
    0.329, 0.362, 0.29, 0.345, 0.149, 0.128, 0.166, 0.235, 0.174, 
    0.276, 0.352, 0.136, 0.43, 0.157, 0.056), ASV69 = c(0.799, 
    0.848, 1.044, 1.34, 1.26, 1.249, 1.861, 1.64, 1.808, 0.711, 
    0.83, 0.935, 0.972, 1.001, 0.945, 0.854, 0.698, 0.715, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ASV12 = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.491, 
    0.533, 0.483, 0.991, 1.04, 1.142, 1.104, 1.234, 1.242, 0.625, 
    0.419, 0.622, 1.029, 0.96, 0.916, 0.956, 1.336, 1.315, 0.678, 
    0.702, 0.814, 0.869, 0.816, 1.213, 1.031, 1.148, 1.165, 0.467, 
    0.591, 0.989, 0.637, 0.714, 1.374, 1.382, 0.691, 1.233), 
    ASV45 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0.86, 1.05, 0.936, 1.513, 1.469, 1.699, 2.105, 1.822, 
    2.076, 0.988, 0.926, 1.149, 1.541, 1.72, 1.656, 1.686, 2.249, 
    2.294, 0.371, 0.421, 0.449, 0.549, 0.506, 0.598, 0.43, 0.56, 
    0.607, 0.406, 0.484, 0.525, 0.51, 0.4, 0.891, 0.89, 0.471, 
    0.633), ASV101 = c(0.703, 0.713, 0.972, 0.896, 0.977, 1.472, 
    1.993, 0.957, 2.238, 0.868, 0.858, 0.722, 0.815, 0.897, 0.851, 
    0.567, 0.754, 0.889, 0, 0, 0, 0, 0, 0.005, 0.003, 0.003, 
    0.002, 0.004, 0, 0, 0.003, 0, 0, 0, 0.004, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0.003, 0, 0, 0, 0, 0, 0, 0, 0), ASV71 = c(2.724, 
    2.672, 3.188, 3.034, 3.191, 2.518, 2.745, 2.039, 2.055, 2.693, 
    2.752, 2.786, 1.244, 1.636, 2.033, 0.897, 1.183, 1.549, 0, 
    0.01, 0.006, 0, 0, 0.005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.002, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 
    ASV27 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0.662, 0.889, 0.727, 1.14, 1.186, 1.083, 1.225, 1.209, 
    1.413, 0.752, 0.781, 0.675, 1.115, 1.215, 1.334, 1.379, 1.497, 
    1.45, 0.541, 0.437, 0.64, 0.438, 0.581, 0.976, 0.701, 0.365, 
    0.368, 0.558, 0.522, 0.307, 0.389, 0.499, 0.455, 0.469, 0.485, 
    0.346), ASV28 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0.401, 0.413, 0.501, 0.665, 0.618, 0.584, 
    0.814, 0.786, 0.958, 0.468, 0.511, 0.427, 0.67, 0.802, 0.77, 
    0.891, 0.961, 0.834, 0.233, 0.19, 0.467, 0.374, 0.169, 0.767, 
    0.647, 0.291, 0.151, 0.341, 0.251, 0.24, 0.241, 0.269, 0.193, 
    0.355, 0.286, 0.329), ASV68 = c(1.624, 1.764, 1.827, 1.926, 
    1.864, 2.001, 1.686, 2.146, 1.852, 1.899, 1.953, 1.738, 1.833, 
    2.4, 1.844, 1.806, 1.474, 1.783, 0.059, 0.057, 0.053, 0, 
    0.012, 0.008, 0, 0, 0, 0.049, 0.045, 0.045, 0.008, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0), ASV170 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0.017, 0.029, 0.015, 0.031, 0.052, 0.052, 
    0.031, 0.041, 0.032, 0.032, 0.042, 0.04, 0.023, 0.048, 0.032, 
    0.053, 0.07, 0.037, 0.12, 0.157, 0.107, 0.139, 0.122, 0.165, 
    0.183, 0.127, 0.08, 0.046, 0.098, 0.061, 0.165, 0.136, 0.08, 
    0.258, 0.06, 0.061), ASV287 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.013, 0, 0, 0.03, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.018, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ASV142 = c(0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.206, 0.069, 0.163, 
    0.07, 0.205, 0.16, 0.21, 0.07, 0.3, 0.092, 0.286, 0.271, 
    0.202, 0.093, 0.122, 0.184, 0.081, 0.193, 0, 0, 0.071, 0.054, 
    0, 0.086, 0.153, 0, 0, 0.067, 0.063, 0.057, 0, 0, 0, 0, 0, 
    0), ASV50 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0.737, 0.537, 0.551, 0.83, 0.93, 0.902, 0.653, 0.841, 
    0.752, 0.703, 0.605, 0.533, 0.895, 0.701, 0.846, 0.706, 0.624, 
    0.609, 1.292, 1.22, 1.527, 1.444, 1.81, 1.551, 1.199, 1.287, 
    1.233, 1.3, 1.547, 1.849, 1.213, 1.918, 2.004, 1.834, 1.439, 
    1.488), ASV76 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 2.042, 1.556, 1.695, 0.113, 0.118, 0.108, 
    0.06, 0.074, 0, 1.979, 1.889, 2.098, 0.58, 0.691, 0.603, 
    0.283, 0.362, 0.29, 0.589, 0.771, 0.056, 0.123, 0.955, 0.024, 
    0.053, 0.535, 0.354, 0.736, 0.629, 0.415, 0.336, 0.949, 0.94, 
    0.927, 0.365, 0.927), ASV19 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.006, 0, 0, 0.005, 
    0, 0, 0, 0, 0, 0, 0, 0.015, 0.025, 0, 0, 0, 0, 0, 0, 0.015, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ASV80 = c(2.341, 2.316, 
    2.766, 2.448, 2.542, 1.785, 2.243, 2.008, 2.083, 2.231, 2.141, 
    2.39, 1.542, 1.594, 1.672, 1.006, 1.204, 1.51, 0.01, 0.019, 
    0.009, 0, 0, 0, 0.004, 0.005, 0, 0.02, 0.012, 0.013, 0.003, 
    0, 0.004, 0, 0.007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0), ASV128 = c(0.085, 0.09, 0.094, 0.282, 
    0.293, 0.395, 0.657, 0.509, 0.777, 0.08, 0.083, 0.101, 0.338, 
    0.419, 0.389, 1.501, 1.122, 1.031, 0.028, 0, 0, 0.03, 0, 
    0, 0.041, 0, 0, 0.027, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ASV72 = c(1.7, 
    1.638, 2.087, 1.451, 1.289, 1.819, 1.782, 1.665, 1.794, 1.649, 
    1.747, 1.153, 1.625, 2.314, 1.978, 2.165, 1.919, 1.822, 0.029, 
    0.053, 0.038, 0.011, 0.015, 0.019, 0.022, 0.017, 0.017, 0.058, 
    0.039, 0.029, 0.013, 0.02, 0, 0.024, 0.012, 0.009, 0, 0.013, 
    0, 0, 0.009, 0, 0, 0, 0, 0.008, 0, 0.012, 0, 0.012, 0, 0, 
    0, 0), ASV47 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0.234, 0.264, 0.236, 0.319, 0.319, 0.373, 0.42, 
    0.342, 0.375, 0.264, 0.308, 0.261, 0.302, 0.4, 0.408, 0.483, 
    0.444, 0.4, 1.134, 1.033, 1.347, 1.465, 1.408, 1.637, 1.241, 
    1.279, 1.154, 1.108, 1.157, 1.613, 1.158, 1.178, 1.818, 1.555, 
    1.255, 1.548), ASV116 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0.425, 0.425, 0.442, 0.57, 0.606, 0.558, 
    0.624, 0.664, 0.647, 0.408, 0.402, 0.387, 0.634, 0.723, 0.731, 
    0.728, 0.858, 0.768, 0.183, 0.149, 0.23, 0.201, 0.214, 0.314, 
    0.351, 0.113, 0.109, 0.176, 0.197, 0.113, 0.145, 0.184, 0.125, 
    0.187, 0.172, 0.086), ASV38 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0.406, 0.378, 0.43, 0.28, 0.274, 
    0.347, 0.307, 0.419, 0.455, 0.327, 0.462, 0.342, 0.317, 0.325, 
    0.334, 0.382, 0.3, 0.291, 1.023, 0.97, 1.367, 1.385, 1.442, 
    1.65, 1.209, 1.719, 1.639, 1.876, 1.627, 1.095, 1.2, 1.527, 
    0.701, 2.21, 1.342, 0.602), ASV160 = c(0.082, 0.108, 0.081, 
    0.167, 0.186, 0.189, 0.259, 0.184, 0.227, 0.103, 0.086, 0.103, 
    0.324, 0.302, 0.303, 1.018, 0.658, 0.733, 0, 0.022, 0.018, 
    0, 0, 0.01, 0, 0.009, 0.008, 0.02, 0.007, 0, 0, 0, 0.01, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0), ASV74 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0.943, 0.934, 0.966, 1.43, 1.459, 1.566, 1.544, 
    1.512, 1.787, 0.966, 1.042, 0.938, 1.436, 1.866, 1.594, 1.907, 
    2.092, 1.734, 0.12, 0.07, 0.146, 0.128, 0.103, 0.235, 0.153, 
    0.082, 0.066, 0.134, 0.105, 0.105, 0.092, 0.131, 0.091, 0.125, 
    0.093, 0.086), ASV7 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0.441, 0.407, 0.476, 0.057, 0.023, 0.028, 
    0.031, 0.011, 0, 0.425, 0.45, 0.572, 0.044, 0.085, 0.064, 
    0.021, 0.039, 0.013, 0.57, 1, 0.028, 0.02, 0.64, 0, 0.011, 
    0.14, 0.208, 0.783, 0.516, 0.357, 0.254, 0.588, 0.383, 0.209, 
    0.287, 0.939), ASV75 = c(0.957, 1.111, 0.827, 1.716, 1.89, 
    1.436, 1.358, 1.753, 1.98, 0.716, 0.72, 1.127, 2.353, 1.436, 
    1.672, 1.087, 2.067, 1.861, 0.084, 0.087, 0.063, 0.083, 0.072, 
    0.075, 0.053, 0.09, 0, 0, 0.089, 0.148, 0.137, 0.075, 0.076, 
    0.097, 0.115, 0.087, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0), ASV90 = c(0, 0, 0, 0.004, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.84, 1.959, 1.614, 1.807, 
    1.973, 2.042, 1.243, 1.274, 1.023, 1.64, 1.553, 1.486, 2.182, 
    1.896, 2.132, 1.709, 1.736, 1.803, 0.186, 0.227, 0.131, 0.124, 
    0.127, 0.139, 0.117, 0.064, 0.084, 0.187, 0.208, 0.104, 0.087, 
    0.115, 0.078, 0.075, 0.079, 0), ASV216 = c(0, 0.016, 0, 0.187, 
    0.192, 0.197, 0.479, 0.206, 0.32, 0, 0, 0, 0.239, 0.285, 
    0.234, 1.619, 0.722, 0.438, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0), ASV77 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.056, 0.043, 0.057, 
    0, 0, 0.095, 0, 0, 0.056, 0, 0.077, 0, 0.078, 0.081, 0.064, 
    0.798, 0.732, 1.04, 1.022, 1.134, 0.973, 0.749, 1.65, 1.497, 
    1.111, 1.063, 1.266, 1.024, 0.986, 1.913, 2.139, 1.137, 1.684
    ), ASV81 = c(1.637, 1.799, 1.768, 1.572, 1.513, 1.574, 1.226, 
    1.573, 1.421, 1.547, 1.792, 1.471, 1.433, 1.993, 1.771, 1.329, 
    1.162, 1.532, 0.051, 0.035, 0.049, 0.014, 0, 0, 0, 0.019, 
    0, 0.066, 0.05, 0.06, 0, 0, 0, 0.016, 0, 0.01, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), class = "data.frame", row.names = c(NA, 
-54L))
library(vegan)
pc = read.csv("mat.csv", header = T)

###subsetting only the ecology abundance information
matrix <- pc[,9:66]

###subsetting categorical variables
cat <- pc[,6:8]

###environmental vectors
vec <- pc[,1:5]

###perform dbRDA
dbrda = dbrda(matrix~Chlorophyll+Temp+Sal, vec, dist="gow")
plot(dbrda)

base r plot

###save summarized data
summary_dbrda <- summary(dbrda)
df <- data.frame(summary_dbrda$sites[,1:4])

df$Station = pc$Station
df$Hours = pc$Hours
df$Treatment = pc$Treatment

###ggplot code
ggplot(df, aes(x=dbRDA1, y=dbRDA2)) + geom_mark_ellipse(aes(x=dbRDA1, y=dbRDA2, fill = Station), alpha=0.2, size=0.1) +
  geom_point(aes(shape = Station, colour = as.factor(Hours), size = Treatment), alpha=0.7) + 
  scale_size_discrete(range = c(3, 6, 50)) +
  theme(axis.title = element_text(colour="black", size=14, face = "bold"),
        axis.text = element_text (colour="black", size=12), 
        panel.background = element_blank(), 
        panel.border = element_rect(colour = "black", fill = NA),
        legend.key=element_blank(), 
        legend.text = element_text(size = 16, colour ="black"), 
        legend.title = element_text(size = 18, face = "bold", colour = "black")) +
  geom_vline(xintercept = c(0), color = "#7D7C7C", linetype = 2) +
  geom_hline(yintercept = c(0), color = "#7D7C7C", linetype = 2) +
  scale_shape_manual(values=c(16, 17, 15)) + 
  scale_color_manual(values=colours) + 
  scale_fill_manual(values = c("#0d0887", "#cc4778", "#f0f921")) +
  guides(shape = guide_legend(override.aes = list(size = 5))) +
  guides(colour = guide_legend(override.aes = list(size = 5)))


ggplot no arrows
当我画这个的时候,我正在失去箭头…我有envfit的经验,我可以从环境变量中计算矢量信息,但不知道如何从基本图中提取箭头到ggplot。谢谢

dba5bblo

dba5bblo1#

调用plot(dbrda)时,箭头的坐标由函数scores计算。此函数生成一个对象列表,其中一个对象名为biplot,包含箭头的坐标。您也可以从summary_dbrda$biplot获取此对象
我们可以简化您的代码,并在ggplot中制作一个专业外观的图,如下所示:

library(vegan)
library(tidyverse)
library(geomtextpath)
library(ggforce)

pc <- read.csv("mat.csv", header = T)

rda <- dbrda(pc[,9:66] ~ Chlorophyll + Temp + Sal, pc[,1:5], dist = "gow") %>%
         scores(tidy = TRUE) %>% 
         split(.[["score"]])

ggplot(rda$sites, aes(dbRDA1, dbRDA2)) +
  geom_hline(yintercept = 0, color = "gray") +
  geom_vline(xintercept = 0, color = "gray") +
  stat_ellipse(data = within(rda$sites, Station <- pc$Station),
                    aes(label = Station, group = Station), color = "gray50", 
               geom = "textpath", hjust = 0.65, vjust = 1.2, linetype = 2) +
  geom_point(aes(fill = factor(pc$Hours), shape  = pc$Treatment), 
             size = 3, color = "gray50") +
  geom_textsegment(aes(x = 0, y = 0, xend = dbRDA1, yend = dbRDA2,
                       label = label), data = rda$biplot, vjust = -0.5,
                   arrow = arrow(25, unit(0.15, "inches")), size = 5) +
  scale_fill_brewer('Hours', palette = "Reds") +
  scale_shape_manual("Treatment", values = c(21, 22)) +
  guides(fill = guide_legend(override.aes = list(shape = 21))) +
  coord_equal() +
  theme_minimal(base_size = 16)

字符串


的数据

相关问题