Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex plot_layout resulting in plots of different widths although having the same area #303

Closed
jospueyo opened this issue Jun 13, 2022 · 1 comment

Comments

@jospueyo
Copy link

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)

Here is the result:

image

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#
"

I had first opened a question in stackoverflow.

@thomasp85
Copy link
Owner

The issue is the same as in #319 - please consult the answer there :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants