teunbrand / ggh4x

ggplot extension: options for tailored facets, multiple colourscales and miscellaneous
https://teunbrand.github.io/ggh4x/
Other
542 stars 33 forks source link

Bug in facet_grid2 scale limits #38

Closed teunbrand closed 3 years ago

teunbrand commented 3 years ago

In the plot below, the second row of panels should have limits c(1, 2) but shows limits 1-10.

library(ggplot2)
library(ggh4x)

df <- data.frame(
  x = 1,
  y = c(1,10,1,2,1,10),
  grp = c("A", "A", "B", "B", "C", "C"),
  var = rep(c("a", "b"), 3)
)

ggplot(df, aes(x, y)) +
  geom_point() +
  facet_grid2(grp ~ var, scales = "free_y")

Created on 2021-04-16 by the reprex package (v1.0.0)

The axis is correct when there is just a single column.

ggplot(df, aes(x, y)) +
  geom_point() +
  facet_grid2(grp ~ "a", scales = "free_y")

Created on 2021-04-16 by the reprex package (v1.0.0)

teunbrand commented 3 years ago

Yeah should be fixed now