@@ -167,32 +167,36 @@ GuideAxis <- ggproto(
167
167
}
168
168
169
169
opposite <- setdiff(c(" x" , " y" ), aesthetic )
170
- opposite_value <- if (position %in% c(" top" , " right" )) - Inf else Inf
171
170
172
- data_frame(
173
- !! aesthetic : = value ,
174
- !! opposite : = opposite_value
175
- )
171
+ data_frame(!! aesthetic : = value )
176
172
},
177
173
178
174
transform = function (self , params , coord , panel_params ) {
179
175
key <- params $ key
180
176
position <- params $ position
181
177
check <- FALSE
182
178
179
+ aesthetic <- names(key )[! grepl(" ^\\ ." , names(key ))]
180
+ ortho <- setdiff(c(" x" , " y" ), params $ aesthetic )
181
+ override <- switch (position %|| % " " , bottom = , left = - Inf , Inf )
182
+
183
+ if (! (panel_params $ reverse %|| % " none" ) %in% c(" xy" , ortho )) {
184
+ override <- - override
185
+ }
186
+
183
187
if (! (is.null(position ) || nrow(key ) == 0 )) {
184
188
check <- TRUE
185
- aesthetics <- names(key )[! grepl(" ^\\ ." , names(key ))]
186
- if (! all(c(" x" , " y" ) %in% aesthetics )) {
187
- other_aesthetic <- setdiff(c(" x" , " y" ), aesthetics )
188
- override_value <- if (position %in% c(" bottom" , " left" )) - Inf else Inf
189
- key [[other_aesthetic ]] <- override_value
189
+ if (! all(c(" x" , " y" ) %in% aesthetic )) {
190
+ key [[ortho ]] <- override
190
191
}
191
192
key <- coord $ transform(key , panel_params )
192
193
params $ key <- key
193
194
}
194
195
195
196
if (! is.null(params $ decor )) {
197
+ if (! ortho %in% names(params $ decor )) {
198
+ params $ decor [[ortho ]] <- override
199
+ }
196
200
params $ decor <- coord_munch(coord , params $ decor , panel_params )
197
201
198
202
if (! coord $ is_linear()) {
0 commit comments