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

facet_grid(scales = "free") not working #5384

Closed
jromanowska opened this issue Aug 9, 2023 · 4 comments
Closed

facet_grid(scales = "free") not working #5384

jromanowska opened this issue Aug 9, 2023 · 4 comments

Comments

@jromanowska
Copy link

I found a problem with facet_grid when setting scales argument to "free".

I expected both, x and y, vary between the panels of the plot, but only one of them vary.

Here is the code to reproduce the bug (using the code from examples in documentation of facet_grid):

mt <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) +
   geom_point()
# first - checking the fixed scales:
mt + facet_grid(vars(cyl), scales = "fixed") # all fine
# checking other 'free' options:
mt + facet_grid(vars(cyl), scales = "free_y") # all fine
mt + facet_grid(vars(cyl), scales = "free_x") # not working
mt + facet_grid(vars(cyl), scales = "free")  # not working
@smouksassi
Copy link

try using facet_wrap
mt + facet_wrap(vars(cyl), scales = "free",ncol=1) #

@jromanowska
Copy link
Author

Thank you, but I actually need the grid - in my work, I want to stratify by two variables and I would like to see varying x and y scales in each of the small panels.

@smouksassi
Copy link

this is not how facet_grid is designed as it is no longer a grid if you vary both
hard to help you without understanding fully what you are really trying to do.

@jromanowska
Copy link
Author

OK, I understand, I will try another way to achieve my goal. Thank you for your time!

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

2 participants