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

Blank first page created by marrangeGrob if facets used in ggplot #33

Closed
kotliary opened this issue Jun 10, 2016 · 2 comments
Closed

Blank first page created by marrangeGrob if facets used in ggplot #33

kotliary opened this issue Jun 10, 2016 · 2 comments

Comments

@kotliary
Copy link

kotliary commented Jun 10, 2016

Here is a minimal reproducible example:

require(dplyr)
require(ggplot2)
require(gridExtra)

p=list()
df = mtcars %>%
  group_by(gear, carb) %>%
  summarise(n=n()) %>%
  ungroup() %>%
  mutate(gear=factor(gear), carb=factor(carb))
p[[1]] = ggplot(df, aes(carb, n, fill=carb)) + 
  facet_wrap(~gear, nrow=1) +
  geom_bar(stat="identity")

ggsave("testm.pdf", marrangeGrob(grobs = p, nrow=1, ncol=1, top=NULL))
ggsave("test.pdf", arrangeGrob(grobs = p))

I get testm.pdf with first blank page, but test.pdf is without.
If facet_wrap line is commented, both files are similar.

@baptiste
Copy link
Owner

baptiste commented Jun 10, 2016

There does seem to be a problem, but honestly I've given up chasing breakage caused by changes in gtable and ggplot2. This might work for you,

grid.draw.arrangelist <- function(x, ...) {
  for(ii in seq_along(x)){
    if(ii>1) grid.newpage() 
     grid.draw(x[[ii]])
}
}

@dmckean
Copy link

dmckean commented Nov 8, 2016

@baptiste that fixed it for me

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

3 participants