Closed teunbrand closed 4 years ago
Note to self:
Probably best to make the function overrule the init_scales()
function in the Facet*
ggprotos to accept custom scales. Alternative would be to make a new facet function, but that would lose all flexibility the current facetting options provide.
The following worked on data in the wild:
nfacet$init_scales <- function(layout, x_scale = NULL, y_scale = NULL, params) {
scales <- list()
if (!is.null(x_scale)) {
scales$x <- lapply(seq_len(max(layout$SCALE_X)), function(i) {x_scale$clone()})
}
if (!is.null(y_scale)) {
scales$y <- list(
upper = scale_y_continuous(trans = "reverse", expand = c(0,0), name = "",
labels = function(x) {paste0(x / 1e6, "Mb")}),
lower = scale_y_continuous(trans = "reverse", expand = c(0,0), name = "",
limits = c(1, -1), oob = squish,
breaks = c(-1, 0, 1))
)
}
scales
}
This is now implemented in the dev branch.
Currently, it is a bit of a pain to precisely control what the limits of a facet are. Maybe, there might something that can be done to give more control, something that would work like the following: