Repository navigation
Closed
Description
There are a number of issues that surround expansion and limiting, which is treated differently in various coordinate systems. It would be nice if specifying xlim and ylim were like specifying scale_(x|y)_*(limits = ...), and if scale expansion were identical for scale_(x|y)_continuous(trans = ...) and coord_trans((x|y) = ...).
Related issues:
- Scale expand value from scales ignored when coord_cartesian ylim is used #3270: interaction between xlim/ylim and expand
NAlimits in coords #2907: AllowingNAin xlim/ylim as one can do in the scalelimits- sqrt_trans, scale limit expansion, and missing breaks #980: breaks for expanded scales with transformations
- Secondary axis doesn't show axis ticks or labels with coord_trans #2990, Remove extra space created by
coord_trans#3338: expansion behaviour incoord_trans()
I think these could almost all be handled in the relatively new ViewScale class, whose objects are currently being created here (this will probably change):
Lines 139 to 161 in 6c2fe76
| view_scales_from_scale <- function(scale, coord_limits = NULL, expand = TRUE) { | |
| expansion <- if (expand) expand_default(scale) else expand_scale(0, 0) | |
| limits <- scale$get_limits() | |
| if (is.null(coord_limits)) { | |
| continuous_range <- scale$dimension(expansion, limits) | |
| } else { | |
| continuous_range <- range(scale$transform(coord_limits)) | |
| continuous_range <- expand_range4(continuous_range, expansion) | |
| } | |
| aesthetic <- scale$aesthetics[1] | |
| view_scales <- list( | |
| view_scale_primary(scale, limits, continuous_range), | |
| sec = view_scale_secondary(scale, limits, continuous_range), | |
| arrange = scale$axis_order(), | |
| range = continuous_range | |
| ) | |
| names(view_scales) <- c(aesthetic, paste0(aesthetic, ".", names(view_scales)[-1])) | |
| view_scales | |
| } |
Activity
paleolimbot commentedon Jun 18, 2019
In a slightly similar way, coordinate systems should probably be able to replace scale defaults that aren't explicitly set (should they?). Off the top of my head,
coord_trans()should probably be able to coerce the (unset) breaks and labels on the transformed axes totrans$breaksortrans$labels, and there is one open issue on something similar withcoord_fixed()(#2888)lock commentedon Dec 29, 2019
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/