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() throws error with geom_col() and coord_flip() #143

Closed
UweBlock opened this issue May 6, 2019 · 2 comments
Closed

facet_zoom() throws error with geom_col() and coord_flip() #143

UweBlock opened this issue May 6, 2019 · 2 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@UweBlock
Copy link

UweBlock commented May 6, 2019

While preparing an answer to Using ggplot2, can I insert a break in the axis? on SO, I noticed that facet_zoom() does not work for horizontal bar charts, i.e., it throws an error when used together with geom_col() and coord_flip():

df <- data.frame(a = c(1,2,3,500), b = c('a1', 'a2','a3', 'a4'))
library(ggforce)
ggplot(df) + 
  aes(x = b, y = a) +
  geom_col() + 
  coord_flip() +
  facet_zoom(ylim = c(0, 10))

Error in scale_index[[i]] : subscript out of bounds

When coord_flip() is removed the code works without any error but creates only vertical bar charts.

Extract from devtools::session_info():

version R version 3.5.3 (2019-03-11)
os Windows 10 x64
...
ggforce * 0.2.2 2019-04-23 [1] CRAN (R 3.5.3)
ggplot2 * 3.1.1 2019-04-07 [1] CRAN (R 3.5.3)

@pgcudahy
Copy link

pgcudahy commented Jul 2, 2019

I get the same error when trying to use geom_pointrange and coord_flip using

 version  R version 3.4.4 (2018-03-15)
 os       Ubuntu 18.04.2 LTS
...
 ggforce     * 0.2.2.9000 2019-07-02 [1] Github (thomasp85/ggforce@b771cec)
 ggplot2     * 3.2.0      2019-06-16 [1] CRAN (R 3.4.4)

@thomasp85 thomasp85 added the bug an unexpected problem or unintended behavior label Jan 18, 2024
@thomasp85
Copy link
Owner

facet_zoom was never able to work with coord_flip() but other errors prevented the evaluation to reach the point where the facet could inspect the coord and throw an appropriate error. This is now fixed so a better error is thrown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants