-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
NA
limits in coords #2907: AllowingNA
in 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 | |
} |