我有两个如下所示的数据集:
#数据集 1
structure(list(dataset1 = 1:86, x = c(24.22055, 24.61821, 24.60858,
24.5963, 24.66904, 24.682, 24.74323, 24.84038, 25.02606, 25.00763,
24.99861, 25.00901, 24.99273, 24.98789, 24.99308, 24.97615, 24.9572,
24.95962, 24.93451, 25.08111, 24.97653, 24.92734, 24.96208, 25.03111,
25.00242, 24.95385, 24.99345, 25.03311, 24.93516, 24.95163, 24.94859,
25.07071, 25.15814, 25.22433, 25.3163, 25.22823, 25.34902, 25.4118,
25.40885, 25.35868, 25.34709, 25.24046, 25.31097, 25.32868, 25.41141,
24.92474, 24.90951, 24.9927, 25.0052, 24.94954, 25.15449, 25.10164,
25.03112, 24.97345, 25.03352, 25.11059, 25.05391, 25.05766, 25.06176,
25.17039, 25.17868, 25.1053, 25.0568, 25.08028, 25.137, 25.36559,
25.06363, 25.26306, 25.16708, 25.14826, 25.06046, 24.99418, 25.19738,
25.20072, 25.24073, 25.18705, 25.18142, 25.16747, 25.1235, 25.38767,
25.37099, 25.30558, 25.35074, 25.33528, 25.32482, 25.32328),
y = c(22.25462, 21.88752, 21.89172, 21.88356, 21.86319, 21.80782,
21.7451, 21.70914, 21.68861, 21.66829, 21.67942, 21.67475,
21.67994, 21.67462, 21.67405, 21.67494, 21.66842, 21.65091,
21.6657, 21.68427, 21.66878, 21.6711, 21.66772, 21.63123,
21.64916, 21.65174, 21.65686, 21.63292, 21.64039, 21.53591,
21.64633, 21.62177, 21.61304, 21.60609, 21.594, 21.60413,
21.59069, 21.58264, 21.58277, 21.57736, 21.57457, 21.57674,
21.56562, 21.49258, 21.48584, 21.74852, 21.73081, 21.75594,
21.66646, 21.70782, 21.67075, 21.66456, 21.64514, 21.65763,
21.66863, 21.64658, 21.63672, 21.62677, 21.65441, 21.61994,
21.61754, 21.65159, 21.62676, 21.61157, 21.60181, 21.65121,
21.61303, 21.61424, 21.61419, 21.6258, 21.59797, 21.61477,
21.5879, 21.58918, 21.61834, 21.56725, 21.61358, 21.61456,
21.57619, 21.592, 21.58095, 21.52847, 21.57284, 21.56755,
21.56847, 21.49455), z = c(53.52483, 53.49427, 53.49971,
53.52014, 53.46777, 53.51018, 53.51168, 53.45048, 53.28533,
53.32408, 53.32197, 53.31623, 53.32733, 53.33749, 53.33287,
53.34891, 53.37439, 53.38947, 53.39978, 53.23462, 53.35469,
53.40156, 53.3702, 53.33767, 53.34843, 53.39441, 53.34969,
53.33398, 53.42445, 53.51247, 53.40507, 53.30752, 53.22882,
53.16958, 53.0897, 53.16764, 53.06029, 53.00556, 53.00838,
53.06396, 53.07834, 53.1828, 53.12341, 53.17874, 53.10275,
53.32674, 53.35968, 53.25136, 53.32834, 53.34264, 53.17476,
53.2338, 53.32374, 53.36892, 53.29785, 53.24283, 53.30937,
53.31556, 53.28384, 53.20967, 53.20378, 53.24311, 53.31644,
53.30816, 53.26118, 52.9832, 53.32334, 53.1227, 53.21872,
53.22594, 53.34158, 53.39105, 53.21472, 53.2101, 53.14093,
53.2457, 53.205, 53.21797, 53.30031, 53.02033, 53.04806,
53.16595, 53.07643, 53.09717, 53.10672, 53.18217)), class = "data.frame", row.names = c(NA,
-86L))
#数据集2
structure(list(dataset2 = 1:16, x1 = c(24.702, 24.64061, 24.64624,
24.699, 24.68064, 24.65854, 24.75148, 24.58633, 24.73463, 24.59992,
24.65293, 24.60753, 24.62394, 25.3416, 24.71006, 24.67719), y1 = c(21.87799,
21.89606, 21.9034, 21.8859, 21.89083, 21.90291, 21.8491, 21.93269,
21.87262, 21.87465, 21.90029, 21.87801, 21.87661, 21.64635, 21.83719,
21.90565), z1 = c(53.42002, 53.46333, 53.45036, 53.4151, 53.42853,
53.43855, 53.39942, 53.48098, 53.39274, 53.52543, 53.44677, 53.51446,
53.49945, 53.01205, 53.45276, 53.41716)), class = "data.frame", row.names = c(NA,
-16L))
我已经编写了一个代码来根据 ggtern 包绘制内核密度轮廓。
# density plot for dataset 1
plot1 <- ggtern(data = test,aes(x=x, y=y, z=z))
plot1+ stat_density_tern(geom="polygon",
aes(fill = ..level..,
alpha = ..level..)) +
theme_rgbw() +
labs(title = "Example Density/Contour Plot") +
scale_fill_gradient(low = "lightblue",high = "blue") +
guides(color = "none", fill = "none", alpha = "none")+
scale_T_continuous (limits = c(0.225,0.215))+
scale_L_continuous (limits= c(0.255,0.245))+
scale_R_continuous (limits = c(0.53,0.54))
# density plot for dataset 2
plot2 <- ggtern(data = test2,aes(x=x1, y=y1, z=z1))
plot2 + stat_density_tern(geom="polygon",
aes(fill = ..level..,
alpha = ..level..)) +
theme_rgbw() +
labs(title = "Example Density/Contour Plot") +
scale_fill_gradient(low = "lightgreen",high = "green") +
guides(color = "none", fill = "none", alpha = "none")+
scale_T_continuous (limits = c(0.225,0.215))+
scale_L_continuous (limits= c(0.255,0.245))+
scale_R_continuous (limits = c(0.53,0.54))
我想做的下一步是将plot1 与plot2 重叠。我想知道是否有人知道如何实现这一目标。谢谢。