Quero organizar o enredo em uma ordem específica.
library(ggpubr)
data("ToothGrowth")
data("mtcars")
mtcars$name <- rownames(mtcars)
mtcars$cyl <- as.factor(mtcars$cyl)
# create boxplot
bxp <- ggboxplot(ToothGrowth, x = "dose", y = "len", color = "dose", palette = "jco")
# create dotplot
dp <- ggdotplot(ToothGrowth, x = "dose", y = "len", color = "dose", palette = "jco", binwidth = 1)
# create scatterplot
sp = ggscatter(mtcars, x = "wt", y = "mpg", add = "reg.line", conf.int = TRUE, color = "cyl", palette = "jco", shape = "cyl")+
stat_cor(aes(color = cyl), label.x = 3)
# arrange the plots
ggarrange(sp, # First row with scatter plot
ggarrange(bxp, dp, ncol = 2, labels = c("B", "C")), # Second row with box and dot plots
nrow = 2,
labels = "A") # Labels of the scatter plot
Organizar os gráficos dessa maneira me deu o resultado.
Mas quero que a saída de outra maneira, como o gráfico de dispersão, esteja no painel inferior e bx e bp no painel superior. tentei
ggarrange(bxp, dp, ggarrange(sp, labels = c("C"), nrow = 1),
nrow = 2, ncol = 2, labels=c("A", "B"))
Mas me deu o seguinte:
O gráfico de dispersão não é preenchido no painel inferior. Está em um canto do painel
Experimente isso.