我想把情节按一定的顺序排列。
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
字符串
以这种方式安排这些图就可以得到输出。
的数据
但是,我希望以另一种方式输出,例如散点图应该在下窗格中,而bx和bp应该在上窗格中。
ggarrange(bxp, dp, ggarrange(sp, labels = c("C"), nrow = 1),
nrow = 2, ncol = 2, labels=c("A", "B"))
型
但它给了我如下:
的
散点图没有用下窗格填充。它在窗格的一个角落里
1条答案
按热度按时间gr8qqesn1#
试试这个.
字符串
的数据