Skip to content

Single strategy for scale expansion/limiting that works with transformations #3371

Closed

Description

@paleolimbot

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:

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):

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

  1. paleolimbot commented on Jun 18, 2019

    @paleolimbot
    MemberAuthor

    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 to trans$breaks or trans$labels, and there is one open issue on something similar with coord_fixed() (#2888)

  2. lock commented on Dec 29, 2019

    @lock

    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/

  3. locked and limited conversation to collaborators on Dec 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions