3

-package からの三値プロットと通常のプロットを並べて( in 経由grid.arrangegridExtra)配置しようとしています。ただし、三角図の美学とラベルの位置は削除されます。ggternggplot2

これはバグのようです。この問題を回避し、私が探している出力を生成するためのポインタは大歓迎です。

再現可能な例:

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'

grid.arrange

三角図は次のようになります。

print(tern.plot)

tern.plot

4

1 に答える 1