Figure Sizing: what is the best strategy when using facets


#1

In the chapter Graphics for Communication in R for Data Science, @hadley discusses figure sizing and gives some advice to keep consistency in the document. I’ve been following the tips and I think they work very well when you don’t have many panels. This time, however, I am using a facet_wrap to create a 4-row plot. I would like each row/panel to have the same aspect as a simple plot. More specifically: assume I have set fig.width=6, fig.asp=0.618 and out.with="70%" as suggested, how do I obtain this figure sizing for each panel of my plot?


#2

I’m not sure exactly what you mean based on your example. If it’s a faceted plot with four rows, there is no way to maintain the same aspect ratio for the individual facets and the entire chart (you’re stacking them on top of each other, so if the width = 6, in all four cases, their combined and individual heights cannot be the same).


#3

I’ve tried many different things based on @yihui answer in this stackoverflow thread. The idea would be to keep the fig.width=6 for each row and set the fig.height accordingly. But I could not figure out a solution so far. But I am not sure this strategy makes sense. I think customizing other aspects of the plot easier when using facets than creating separate plots and using something like gridExtra.


#4

What is it you’re trying to hold constant? If they’re rows, then the width will be uniform. If you want the individual facets to be a certain height, then the total height will be a multiple of that…

gridExtra and other ggplot2 extensions can definitely help:
http://www.ggplot2-exts.org/gallery/

If you take a look at the egg package, it has a nice figure that illustrates which portions of a chart take up what space:


ggplot2_layouts