Как совместить DiagrammeR с другими графиками на одной панели?
Я хотел бы включить диаграмму из DiagrammeR в многопанельный график, например, из ggplot2, но, к сожалению, DiagrammeR не пишет на графическом устройстве. Кто-нибудь знает как это сделать?
Вот мой пример, который отлично работает с двумя графиками ggplot2, но не тогда, когда я объединяю его с DiagrammeR.
library(ggplot2)
library(DiagrammeR)
library(grid)
library(gridExtra)
set.seed(1)
x <- 1:10
y <- x*rnorm(n=10, mean = 1, sd = 0.2)
data <- data.frame(x,y)
plot <- ggplot(data, aes(x=x,y=y)) + geom_point()
plot1 <- arrangeGrob(plot, top = textGrob("A", x = unit(0.0, "npc"), y =
unit(1, "npc"), just=c("left","top"), gp=gpar(col="black", fontsize=14,
fontfamily="Times")))
plot2 <- arrangeGrob(plot, top = textGrob("B", x = unit(0.0, "npc"), y =
unit(1, "npc"), just=c("left","top"), gp=gpar(col="black", fontsize=14,
fontfamily="Times")))
grid.arrange(plot1, plot2)
d <- grViz("
digraph boxes_and_circles {
# add node statements
node [shape = box]
A; B
node [shape = box]
C; D
A->C; B->D
}
")
d
d <- arrangeGrob(d, top = textGrob("B", x = unit(0.0, "npc"), y = unit(1,
"npc"), just=c("left","top"), gp=gpar(col="black", fontsize=14,
fontfamily="Times")))
grid.arrange(plot1, d)