How to plot using facet_wrap, over multiple pages as a .pdf files in r cran I am using ggplot, to compare 114 unique studies for a particular variable I'm interested in.
This is what I have used.
ggplot(steps, aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,)) + facet_wrap(~id_study,)

Whilst this works, all 114 studies are plotted on one page and the formatting is all squashed. How do I split this over 4x4 pages ?

Many thanks

S

edit ****

As there are 114 unique studies, I have 5 pages in total 
1)
ggplot(steps, aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,))+ facet_wrap_paginate(~id_study, nrow = 5, ncol = 5, scales
 = &quot;fixed&quot;, shrink = TRUE, labeller = &quot;label_value&quot;, as.table = TRUE, switch = NULL, drop = TRUE, dir = &quot;h&quot;, strip.position = &quot;top&quot;, page = 1)  

2)
ggplot(steps, aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,))+ facet_wrap_paginate(~id_study, nrow = 5, ncol = 5, scales
 = &quot;fixed&quot;, shrink = TRUE, labeller = &quot;label_value&quot;, as.table = TRUE, switch = NULL, drop = TRUE, dir = &quot;h&quot;, strip.position = &quot;top&quot;, page = 2)  

3)
ggplot(steps, aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,))+ facet_wrap_paginate(~id_study, nrow = 5, ncol = 5, scales
 = &quot;fixed&quot;, shrink = TRUE, labeller = &quot;label_value&quot;, as.table = TRUE, switch = NULL, drop = TRUE, dir = &quot;h&quot;, strip.position = &quot;top&quot;, page = 3) 

4)
 ggplot(steps, aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,))+ facet_wrap_paginate(~id_study, nrow = 5, ncol = 5, scales
 = &quot;fixed&quot;, shrink = TRUE, labeller = &quot;label_value&quot;, as.table = TRUE, switch = NULL, drop = TRUE, dir = &quot;h&quot;, strip.position = &quot;top&quot;, page = 4) 

5)

ggplot(steps, aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,))+ facet_wrap_paginate(~id_study, nrow = 5, ncol = 5, scales
 = &quot;fixed&quot;, shrink = TRUE, labeller = &quot;label_value&quot;, as.table = TRUE, switch = NULL, drop = TRUE, dir = &quot;h&quot;, strip.position = &quot;top&quot;, page = 5)

all of these into 1 page?
thank you
Depending on the shape of your plots, it might make sense to create four separate plots. I suggest this just because it makes sense to show the axes and labels on each individual page, otherwise it could be that the reader would have to always flips back to e.g. page 1 to see what the scales are.

I would probably do something like a 6 (rows) by 5 (columns) on each page, assuming portrait page orientation. Then you need to just adjust your code to do something like this (as pseudo-code):

page1 &lt;- ggplot(steps[0:30]), aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,)) + facet_wrap(~id_study,)

page2 &lt;- ggplot(steps[30:60]), aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,)) + facet_wrap(~id_study,)

page3 &lt;- ggplot(steps[60:90]), aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,)) + facet_wrap(~id_study,)

page4 &lt;- ggplot(steps[90:114]), aes(x=factor(edu))) + geom_bar(aes(y = (..count..), group = id_study,)) + facet_wrap(~id_study,)


Then continue to export the images as you require, for example:

ggsave('./first_page_plots.pdf', page1, dpi=600)


check out more save options here.