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_zoom won't zoom in xlim/ylim if axis limit set before (like in y_scale_continuous) #137

Closed
liuyanguu opened this issue Mar 30, 2019 · 5 comments

Comments

@liuyanguu
Copy link

facet_zoom is a great feature but surely challenging to implement...
If ylim or xlim is set in the parent plot, it won't work to further set ylim or xlim in the zoom-in plot. The zoom in range will just follow the setting before. This is not a big issue though, just a notice.
It might relate to issue #133 for the same reason.
I searched if there is a way to cross it in ggplot but haven't found a solution. I appreciate any advice.

library(ggplot2)
library(ggforce)
ggplot(iris, aes(Petal.Length, Petal.Width, colour = Species)) +
  geom_point() +
  scale_y_continuous(limits = c(0,2)) +
  facet_zoom(ylim = c(0,1), horizontal = F)

same for:

ggplot(iris, aes(Petal.Length, Petal.Width, colour = Species)) +
  geom_point() +
  coord_cartesian(ylim = c(0,2)) +
  facet_zoom(ylim = c(0,1), horizontal = F)
packageVersion("ggforce")

‘0.2.1.9000’

@LuZhangH
Copy link

@liuyanguu Hi, Did you manage to figure out the solution?

@Izymil
Copy link

Izymil commented Mar 3, 2021

I join the subject - It would be extremely useful to find permanent solution or at least some ad-hoc fix. I struggle with some ggplot, that by default is zoomed. What I would like to achieve is to force ggplot to draw it in full scale and than use facet_zoom to show the zoomed panel. But when I force ggplot to show the full y scale (by using 'limits' inside 'scale_y_continous" or 'coord_carthesian'), then facet_zoom does not zoom - it reproduce the same limits I set for the main plot.

@liuyanguu
Copy link
Author

@liuyanguu Hi, Did you manage to figure out the solution?

I think it is what it is. I guess ggforce::facet_zoom on purpose inherits the limits set in scale_x_continuous and scale_x_continuous. I guess to avoid conflicts.

@thomasp85
Copy link
Owner

This should now work when setting limits on the scales. There is unfortunately no way for a facet to intervene with the limits imposed by the coordinate system so that is the best I can do

@LuZhangH
Copy link

LuZhangH commented Sep 2, 2022 via email

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