@@ -167,32 +167,36 @@ GuideAxis <- ggproto(
167167 }
168168
169169 opposite <- setdiff(c(" x" , " y" ), aesthetic )
170- opposite_value <- if (position %in% c(" top" , " right" )) - Inf else Inf
171170
172- data_frame(
173- !! aesthetic : = value ,
174- !! opposite : = opposite_value
175- )
171+ data_frame(!! aesthetic : = value )
176172 },
177173
178174 transform = function (self , params , coord , panel_params ) {
179175 key <- params $ key
180176 position <- params $ position
181177 check <- FALSE
182178
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+
183187 if (! (is.null(position ) || nrow(key ) == 0 )) {
184188 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
190191 }
191192 key <- coord $ transform(key , panel_params )
192193 params $ key <- key
193194 }
194195
195196 if (! is.null(params $ decor )) {
197+ if (! ortho %in% names(params $ decor )) {
198+ params $ decor [[ortho ]] <- override
199+ }
196200 params $ decor <- coord_munch(coord , params $ decor , panel_params )
197201
198202 if (! coord $ is_linear()) {
0 commit comments