我有一个问题,geom_hex_tern
可以完美地处理单个图,但是当我制作刻面时,十六进制 bin 的大小和形状会变形。
library(tidyverse)
library(ggtern)
# My data
dat <- structure(list(Fact2 = c(0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
0.24, 0.28, 0.28, 0.28, 0.28, 0.28), x = c(0.05, 0.1, 0.1, 0.1,
0.15, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.25, 0.25, 0.25, 0.25,
0.3, 0.3, 0.35, 0.35, 0.4, 0.4, 0.4, 0.45, 0.45, 0.45, 0.45,
0.5, 0.5, 0.5, 0.5, 0.55, 0.55, 0.55, 0.6, 0.6, 0.6, 0.65, 0.7,
0.75, 0.05, 0.1, 0.2, 0.3, 0.45), y = c(0.6, 0.5, 0.6, 0.7, 0.55,
0.1, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.35, 0.4, 0.45, 0.5, 0.3,
0.4, 0.25, 0.4, 0.3, 0.35, 0.4, 0.2, 0.25, 0.35, 0.45, 0.05,
0.15, 0.2, 0.25, 0.1, 0.2, 0.3, 0.05, 0.1, 0.25, 0.1, 0.05, 0.05,
0.55, 0.5, 0.55, 0.2, 0.25), z = c(0.35, 0.4, 0.3, 0.2, 0.3,
0.7, 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.4, 0.35, 0.3, 0.25, 0.4,
0.3, 0.4, 0.25, 0.3, 0.25, 0.2, 0.35, 0.3, 0.2, 0.1, 0.45, 0.35,
0.3, 0.25, 0.35, 0.25, 0.15, 0.35, 0.3, 0.15, 0.25, 0.25, 0.2,
0.4, 0.4, 0.25, 0.5, 0.3), wt = c(0.027, 0.02, 0.016, 0.017,
0.043, 0.018, 0.02, 0.023, 0.037, 0.02, 0.018, 0.02, 0.015, 0.043,
0.031, 0.033, 0.036, 0.029, 0.015, 0.022, 0.036, 0.022, 0.017,
0.02, 0.022, 0.018, 0.019, 0.023, 0.02, 0.065, 0.038, 0.043,
0.02, 0.023, 0.063, 0.02, 0.018, 0.025, 0.042, 0.016, 0.015,
0.019, 0.017, 0.018, 0.039)), row.names = c(NA, -45L), class = c("tbl_df",
"tbl", "data.frame"))
# PLot Fact2 == 0.24 - OK
filter(dat, Fact2 == 0.24) %>%
ggtern(aes(x = x, y = y, z = z)) +
geom_hex_tern(binwidth = 0.05, colour = "black", aes(value = wt))
# PLot Fact2 == 0.28 - OK
filter(dat, Fact2 == 0.28) %>%
ggtern(aes(x = x, y = y, z = z)) +
geom_hex_tern(binwidth = 0.05, colour = "black", aes(value = wt))
# plot both together - weird hex bin size/shape
ggtern(dat, aes(x = x, y = y, z = z)) +
geom_hex_tern(binwidth = 0.05, colour = "black", aes(value = wt)) +
facet_wrap(~Fact2)
前两个图看起来不错,但是当通过分面绘制在一起时,这些箱被弄乱了,这似乎只有在我绘制稀疏数据(几个箱)时才会发生,当我在每个图上有很多点时分面工作正常。任何关于如何让多面图看起来正常的建议将不胜感激。