Skip to content

Polish #6070 #6213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion R/coord-.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ Coord <- ggproto("Coord",
empty <- vapply(guides, inherits, logical(1), "GuideNone")
guide_params <- panel_params$guides$get_params(aesthetics)
aesthetics <- aesthetics[!empty]
# Guides are not subject to reverse logic
temp_params <- modify_list(panel_params, list(reverse = "none"))

guide_params[!empty] <- Map(
function(guide, guide_param, scale) {
guide_param <- guide$train(guide_param, scale)
guide_param <- guide$transform(guide_param, self, panel_params)
guide_param <- guide$transform(guide_param, self, temp_params)
guide_param <- guide$get_layer_key(guide_param, layers)
guide_param
},
Expand Down
7 changes: 4 additions & 3 deletions R/coord-cartesian-.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ CoordCartesian <- ggproto("CoordCartesian", Coord,
self$range(panel_params)
},

transform = function(self, data, panel_params) {
reverse <- self$reverse %||% "none"
transform = function(data, panel_params) {
reverse <- panel_params$reverse %||% "none"
x <- panel_params$x[[switch(reverse, xy = , x = "reverse", "rescale")]]
y <- panel_params$y[[switch(reverse, xy = , y = "reverse", "rescale")]]
data <- transform_position(data, x, y)
Expand All @@ -113,7 +113,8 @@ CoordCartesian <- ggproto("CoordCartesian", Coord,
setup_panel_params = function(self, scale_x, scale_y, params = list()) {
c(
view_scales_from_scale(scale_x, self$limits$x, params$expand[c(4, 2)]),
view_scales_from_scale(scale_y, self$limits$y, params$expand[c(3, 1)])
view_scales_from_scale(scale_y, self$limits$y, params$expand[c(3, 1)]),
reverse = self$reverse %||% "none"
)
},

Expand Down
1 change: 1 addition & 0 deletions R/coord-radial.R
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ polar_bbox <- function(arc, margin = c(0.05, 0.05, 0.05, 0.05),
return(list(x = c(0, 1), y = c(0, 1)))
}
arc <- sort(arc)
inner_radius <- sort(inner_radius)

# X and Y position of the sector arc ends
xmax <- 0.5 * sin(arc) + 0.5
Expand Down
5 changes: 3 additions & 2 deletions R/coord-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
target_crs <- panel_params$crs

# CoordSf doesn't use the viewscale rescaling, so we just flip ranges
reverse <- self$reverse %||% "none"
reverse <- panel_params$reverse %||% "none"
x_range <- switch(reverse, xy = , x = rev, identity)(panel_params$x_range)
y_range <- switch(reverse, xy = , y = rev, identity)(panel_params$y_range)

Expand Down Expand Up @@ -268,7 +268,8 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
y_range = y_range,
crs = params$crs,
default_crs = params$default_crs,
!!!viewscales
!!!viewscales,
reverse = self$reverse %||% "none"
)

# Rescale graticule for panel grid
Expand Down
5 changes: 3 additions & 2 deletions R/coord-transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ CoordTrans <- ggproto("CoordTrans", Coord,
transform = function(self, data, panel_params) {
# trans_x() and trans_y() needs to keep Inf values because this can be called
# in guide_transform.axis()
reverse <- self$reverse %||% "none"
reverse <- panel_params$reverse %||% "none"
x_range <- switch(reverse, xy = , x = rev, identity)(panel_params$x.range)
y_range <- switch(reverse, xy = , y = rev, identity)(panel_params$y.range)
trans_x <- function(data) {
Expand All @@ -159,7 +159,8 @@ CoordTrans <- ggproto("CoordTrans", Coord,
setup_panel_params = function(self, scale_x, scale_y, params = list()) {
c(
view_scales_from_scale_with_coord_trans(scale_x, self$limits$x, self$trans$x, params$expand[c(4, 2)]),
view_scales_from_scale_with_coord_trans(scale_y, self$limits$y, self$trans$y, params$expand[c(3, 1)])
view_scales_from_scale_with_coord_trans(scale_y, self$limits$y, self$trans$y, params$expand[c(3, 1)]),
reverse = self$reverse
)
},

Expand Down
Loading