ggplot2
has the ability to change the margins between a faceted plot using the argument panel.margin
in opts
. This seems to change both horizontal and vertical spacing. Is there a way to change the spacing of either horizontal or vertical without changing the other?
An example with outcome and desired outcome:
mtcars[, c("cyl", "am", "gear")] <- lapply(mtcars[, c("cyl", "am", "gear")], as.factor)
p <- ggplot(mtcars, aes(mpg, wt, group = cyl)) +
geom_line(aes(color=cyl)) +
geom_point(aes(shape=cyl)) +
facet_grid(gear ~ am) +
theme_bw()
p + opts(panel.margin = unit(1, "lines"))
So it currently looks like:
How can we make it look more like:
plot.margin
. This feature was asked about a year ago, with the answer to its availability being "not at present". – A5C1D2H2I1M1N2O1R2T1opts
withtheme
and you can move some things independent of another (iepanel.grid.major.y
etc) I figured this may work to use:theme(panel.margin.x = unit(1, "lines"))
but it does not. – Tyler Rinker