我想通过
我知道这似乎是一个错误。非常感谢任何可以解决这个问题并产生我所期望的输出的指针。
一个可重现的例子:
gridExtra
中的grid.arrange
来排列一个三元图和一个常规的ggplot2
图形。然而,三元图的美学和标签位置被移除了。我知道这似乎是一个错误。非常感谢任何可以解决这个问题并产生我所期望的输出的指针。
一个可重现的例子:
library(ggplot2)
library(ggtern)
library(reshape2)
library(gridExtra)
# Some faux data
dat <- replicate(3, runif(5))
dat <- as.data.frame(dat/rowSums(dat))
colnames(dat) <- LETTERS[seq_len(ncol(dat)) + 23]
dat$var <- factor(LETTERS[seq_len(nrow(dat))])
# Make a ternary plot
tern.plot <-
ggplot(data = dat, aes(y=Y, x=X, z=Z, color = var, fill = var)) +
coord_tern() +
geom_point(size = 3)
# Make a stacked barplot
dat.melt <- melt(dat, id.vars = "var", variable.name = "dim")
stacked.plot <-
ggplot(data = dat.melt, aes(x = var, y = value, fill = dim)) +
geom_bar(stat = "identity")
# Arrange the two plots:
grid.arrange(tern.plot, stacked.plot, ncol = 2)
#Warning messages:
#1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
#2: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
# ...
#9: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
print(tern.plot)
ggplot_build
,但没有定义ggplotGrob
,因此该函数会从ggplot2中使用其自己的ggplot_build
。 - baptisteggtern.multi
也可以解决问题。 - Anders Ellern Bilgrauggtern.multi
的人有用 - David Arenburg