@@ -188,39 +188,12 @@ GuideAxisLogticks <- ggproto(
188
188
189
189
# Reconstruct original range
190
190
limits <- transformation $ inverse(scale $ get_limits())
191
- has_negatives <- any(limits < = 0 )
192
- if (has_negatives ) {
193
- large <- max(abs(limits ))
194
- small <- params $ negative_small %|| % min(c(1 , large ) * 0.1 )
195
- limits <- sort(c(small * 10 , large ))
196
- }
197
-
198
- start <- floor(log10(min(limits ))) - 1L
199
- end <- ceiling(log10(max(limits ))) + 1L
200
-
201
- # Calculate tick marks
202
- tens <- 10 ^ seq(start , end , by = 1L )
203
- fives <- tens * 5
204
- ones <- as.vector(outer(setdiff(2 : 9 , 5 ), tens ))
205
191
206
- if (has_negatives ) {
207
- # Filter and mirror ticks around 0
208
- tens <- tens [tens > = small ]
209
- tens <- c(tens , - tens , 0 )
210
- fives <- fives [fives > = small ]
211
- fives <- c(fives , - fives )
212
- ones <- ones [ones > = small ]
213
- ones <- c(ones , - ones )
214
- }
215
-
216
- # Set ticks back into transformed space
217
- ticks <- transformation $ transform(c(tens , fives , ones ))
218
- nticks <- c(length(tens ), length(fives ), length(ones ))
192
+ ticks <- minor_breaks_log(smallest = params $ negative_small )(limits )
193
+ tick_type <- match(attr(ticks , " detail" ), c(10 , 5 , 1 ))
194
+ ticks <- transformation $ transform(ticks )
219
195
220
- logkey <- data_frame0(
221
- !! aesthetic : = ticks ,
222
- .type = rep(1 : 3 , times = nticks )
223
- )
196
+ logkey <- data_frame0(!! aesthetic : = ticks , .type = tick_type )
224
197
225
198
# Discard out-of-bounds ticks
226
199
range <- if (params $ expanded ) scale $ continuous_range else scale $ get_limits()
0 commit comments