Skip to content

Commit 9266f69

Browse files
committed
include reverse settings in panel parameters
1 parent 6e6a5fa commit 9266f69

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

R/coord-cartesian-.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ CoordCartesian <- ggproto("CoordCartesian", Coord,
102102
self$range(panel_params)
103103
},
104104

105-
transform = function(self, data, panel_params) {
106-
reverse <- self$reverse %||% "none"
105+
transform = function(data, panel_params) {
106+
reverse <- panel_params$reverse %||% "none"
107107
x <- panel_params$x[[switch(reverse, xy = , x = "reverse", "rescale")]]
108108
y <- panel_params$y[[switch(reverse, xy = , y = "reverse", "rescale")]]
109109
data <- transform_position(data, x, y)
@@ -113,7 +113,8 @@ CoordCartesian <- ggproto("CoordCartesian", Coord,
113113
setup_panel_params = function(self, scale_x, scale_y, params = list()) {
114114
c(
115115
view_scales_from_scale(scale_x, self$limits$x, params$expand[c(4, 2)]),
116-
view_scales_from_scale(scale_y, self$limits$y, params$expand[c(3, 1)])
116+
view_scales_from_scale(scale_y, self$limits$y, params$expand[c(3, 1)]),
117+
reverse = self$reverse %||% "none"
117118
)
118119
},
119120

R/coord-sf.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
8686
target_crs <- panel_params$crs
8787

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

@@ -268,7 +268,8 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
268268
y_range = y_range,
269269
crs = params$crs,
270270
default_crs = params$default_crs,
271-
!!!viewscales
271+
!!!viewscales,
272+
reverse = self$reverse %||% "none"
272273
)
273274

274275
# Rescale graticule for panel grid

R/coord-transform.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ CoordTrans <- ggproto("CoordTrans", Coord,
134134
transform = function(self, data, panel_params) {
135135
# trans_x() and trans_y() needs to keep Inf values because this can be called
136136
# in guide_transform.axis()
137-
reverse <- self$reverse %||% "none"
137+
reverse <- panel_params$reverse %||% "none"
138138
x_range <- switch(reverse, xy = , x = rev, identity)(panel_params$x.range)
139139
y_range <- switch(reverse, xy = , y = rev, identity)(panel_params$y.range)
140140
trans_x <- function(data) {
@@ -159,7 +159,8 @@ CoordTrans <- ggproto("CoordTrans", Coord,
159159
setup_panel_params = function(self, scale_x, scale_y, params = list()) {
160160
c(
161161
view_scales_from_scale_with_coord_trans(scale_x, self$limits$x, self$trans$x, params$expand[c(4, 2)]),
162-
view_scales_from_scale_with_coord_trans(scale_y, self$limits$y, self$trans$y, params$expand[c(3, 1)])
162+
view_scales_from_scale_with_coord_trans(scale_y, self$limits$y, self$trans$y, params$expand[c(3, 1)]),
163+
reverse = self$reverse %||% "none"
163164
)
164165
},
165166

0 commit comments

Comments
 (0)