拼布导致不同宽度的图,尽管具有相同的区域
我正在用拼布组装11个地块。但是,奇怪的是,尽管在plot_layout()
中定义了相同的区域,但右上图比其他图更窄。这是一个reprex:
create_plot <- function(x=NA){
tibble(name = sample(letters[1:5], 50, replace=T),
value = sample(letters[6:10], 50, replace=T)
) %>%
count(name, value) %>%
ggplot(aes(x=name, y=n, fill=value))+
geom_col(show.legend = F)
}
areas <- c( #top left bottom right
area(1,1,1,4),
area(1,5,1,8),
area(1,9,1,12),
area(2,2,2,5),
area(2,8,2,11),
area(3,2,3,5),
area(3,8,3,11),
area(4,2,4,5),
area(4,8,4,11),
area(5,2,5,5),
area(5,8,5,11)
)
plot(areas)
map(1:11, create_plot) %>%
wrap_plots()+guide_area()+
plot_layout(design = areas)
这是结果:
所有曲线均具有相同的宽度,除了右上方的宽度,这更窄。我还尝试使用带有相同结果的网格字符串:
areas <- "
AAAABBBBCCCC
#DDDD##EEEE#
#FFFF##GGGG#
#HHHH##IIII#
#JJJJ##KKKK#
"
I'm assembling eleven plots with patchwork. But, weirdly, the top right plot is narrower than the others despite having the same area defined in plot_layout()
. Here is a reprex:
create_plot <- function(x=NA){
tibble(name = sample(letters[1:5], 50, replace=T),
value = sample(letters[6:10], 50, replace=T)
) %>%
count(name, value) %>%
ggplot(aes(x=name, y=n, fill=value))+
geom_col(show.legend = F)
}
areas <- c( #top left bottom right
area(1,1,1,4),
area(1,5,1,8),
area(1,9,1,12),
area(2,2,2,5),
area(2,8,2,11),
area(3,2,3,5),
area(3,8,3,11),
area(4,2,4,5),
area(4,8,4,11),
area(5,2,5,5),
area(5,8,5,11)
)
plot(areas)
map(1:11, create_plot) %>%
wrap_plots()+guide_area()+
plot_layout(design = areas)
And here is the result:
All plots have the same width, except the top right one, which is narrower. I also tried using the grid string with the same result:
areas <- "
AAAABBBBCCCC
#DDDD##EEEE#
#FFFF##GGGG#
#HHHH##IIII#
#JJJJ##KKKK#
"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论