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

Increasing the space between plots in plot_grid? #11

Closed
testbird opened this issue Aug 26, 2015 · 4 comments
Closed

Increasing the space between plots in plot_grid? #11

testbird opened this issue Aug 26, 2015 · 4 comments

Comments

@testbird
Copy link

Is it possible to increase the spacing between the plots in plot_grid?

The spacing I found discussed in the docs all seemed to refer to labels within plots.

@clauswilke
Copy link
Contributor

There are two options. One is to increase the margin of the individual plots, by adding something like:

ggplot(...) + theme(plot.margin = unit(c(3,3,3,3), "lines"))

This allows you to specify in detail on which sides of the plots you want more space.

Second, you can just scale all the plots down proportionally, by using something like:

plot_grid(..., scale = 0.9)

In both cases, if this results in misplaced labels, then you can adjust the label positions via the hjust and vjust options of plot_grid().

@testbird
Copy link
Author

Thank you for your answer, I tested these options. Unfortunately, it looks like I have to go back to manual plot positioning and labeling in the text document for now.

The scaling makes all plots (and fonts!) smaller (and wastes space on the outer sides).

Manually adjusting the inner margins seems like more work then positioning the plots manually in the text document. And if one of the plots looks bad with a sqare size (needs to be wider, with larger aspect ratio), increasing the upper and lower margins seems to have ill side effects.

What somehow irritates me is that the appearance of the R plotting is so different depending on the "available output canvas dimensions" defined, even with pdf and svg vector formats. Changing canvas sizes, margins, or changing aspect ratios influences line thickness, relative font size and font overlapping in the final document.
For example, one grid can end up having plot labes (e.g. A,B) of different size than those in another grid.

Taking the canvas size as a reference seems backwards to me. I would have thought all vectors (incl. fonts and line thickness) would be based on constant length units like meters (or any derived, like mm, points, etc.) and these could then be transformed without distortions to whatever canvas as desired (keeping aspect ratio or not).

@crsh
Copy link

crsh commented Jul 27, 2016

Just to add another solution for simple cases (should anyone still be interested), you could simply add an empty plot:

plot_grid(
  plot_a, NULL, plot_b
  , nrow = 1
  , rel_widths = c(1, 0.05, 1)
  , labels = c("A", "", "B")
)

@ykang0929
Copy link

While scale <1, then would marker plots smaller; however, scale >1 would get bigger plot and maybe overlap the closer ones (please try different parameters and get better value).

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

4 participants