I want to specify individual y-axis for each panel of the facet_grid. I followed the example shown here using ggh4x package. I get an error that says Error in rlang::eval_tidy(x, layout) : object '3' not found
Any suggestions?
mtcars$gear <- as.factor(mtcars$gear)
mtcars$cyl <- as.factor(mtcars$cyl)
ggplot(mtcars , aes(x=mpg, y=wt, color=as.factor(cyl) )) +
geom_point(size=3) +
facet_grid(gear~cyl,scales = "free_y") +
theme(legend.position="none") +
ggh4x::facetted_pos_scales(y = list(
gear == `3` ~ scale_y_continuous(limits = c(0, 6), breaks = seq(0, 5, 2.5)),
gear == `4` ~ scale_y_continuous(limits = c(0, 7), breaks = seq(0, 5,3)),
gear == `5` ~ scale_y_continuous(limits = c(0, 5), breaks = seq(0, 5, 1))
))