英文:
Patchwork not following layout correctly
问题
I want four equally sized panels on the second row of my plot but the output is not matching the layout I specify.
library(ggplot2)
library(patchwork)
set seed(1)
df <- data.frame(x = rnorm(10), y = rnorm(10))
p <- ggplot(df, aes(x = x, y = y)) +
geom_point()
layout <- "
AAABBBBB
CCDDEEFF
"
p + p + p + p + p + p + plot_layout(design = layout)
英文:
I want four equally sized panels on the second row of my plot but the output is not matching the layout I specify.
library(ggplot2)
library(patchwork)
set.seed(1)
df<-data.frame(x=rnorm(10),y=rnorm(10))
p <- ggplot(df, aes(x=x,y=y)) +
geom_point()
layout <- "
AAABBBBB
CCDDEEFF
"
p + p + p + p + p + p + plot_layout(design = layout)
答案1
得分: 3
这将产生正确的输出(改编自这里)
(p + p + plot_layout(widths = c(3,5))) /
(p + p + p +p + plot_layout(widths = c(2,2,2,2)))
英文:
This will produce the correct output (adapted from here)
(p + p + plot_layout(widths = c(3,5))) /
(p + p + p +p + plot_layout(widths = c(2,2,2,2)))
答案2
得分: 1
Using different layout design per row:
(p + p + plot_layout(design = "AAABBBBB")) /
(p + p + p + p + plot_layout(design = "CCDDEEFF"))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论