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
geom_sf() and facet_*(..., scales="free"): plot aspect ratio #2651
Comments
I think the real bug is that I believe the bug was introduced as a result of #2594:
versus:
The reason is Line 262 in eecc450
|
What if I want to show some data over USA and Canada, in two different facets? Currently, (without |
The problem is that throughout the ggplot2 code base, the assumption is made that axes can be trained independently of other axes. To implement what you're requesting, one would have to write a training algorithm that trains x and y axes simultaneously while producing a targeted aspect ratio. This is possible in principle, but it's not immediately obvious how to do it in the current code base, at least to me. The best way forward might be to write a new faceting function specifically for this purpose, probably first in the form of an extension package. @thomasp85 may have further insight. |
There are ggplot2 extensions (see http://www.ggplot2-exts.org/gallery/) that should allow you to arrange two maps side by side as such, e.g. patchwork, and (@clauswilke, correct me if I'm wrong) cowplot. |
@batpigandme Yes, that's the other possible approach, make the plots separately and then arrange side-by-side. But then we don't get the power of faceting. |
Oh yeah, of course, I was just offering a workaround! |
Yes, this is a bug - this plot should throw an error message. |
Thanks for the bugfix. I do not know the internals of d = data.frame(x=1:2)
ggplot(d, aes(x=x, y=x)) + geom_point() + facet_wrap(~x, scales="free") |
library(ggplot2)
d = data.frame(x=c(1,100), y=c(1,100), f=c(1, 100))
ggplot(d, aes(x=y, y=y)) + geom_point() + facet_wrap(~f, scales="free") + coord_fixed()
#> Error: coord_fixed doesn't support free scales Created on 2018-05-23 by the reprex package (v0.2.0). |
@clauswilke Thanks for the explanation! I believe this can be closed, right? |
The issue will be automatically closed once the pull request is integrated into the main code base. That hasn’t happened yet. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Setting
scales="free"
infacet_*
resetsgeom_sf
aspect ratio handling, even if not necessary. See reprex below.Without
scales="free"
:With
scales="free"
:scales="free"
should allow facets to have different ranges without altering the plot aspect ratio.The text was updated successfully, but these errors were encountered: