Skip to content

Commit 233a11b

Browse files
committed
User supplied minor breaks should be transformed.
Fixes #1385
1 parent bc2a2a5 commit 233a11b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ version of ggplot.
425425
* New `layer_data()` function extracts the data used for plotting for a given
426426
layer. It's mostly useful for testing.
427427
428+
* User supplied `minor_breaks` can now be supplied on the same scale as
429+
the data, and will be automatically transformed with by scale (#1385).
430+
428431
* You can now suppress the appearance of an axis/legend title (and the space
429432
that would allocated for it) with `NULL` in the `scale_` function. To
430433
use the default lable, use `waiver()` (#1145).

R/scale-.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
266266
breaks <- self$minor_breaks(self$trans$inverse(limits))
267267
breaks <- self$trans$transform(breaks)
268268
} else {
269-
breaks <- self$minor_breaks
269+
breaks <- self$trans$transform(self$minor_breaks)
270270
}
271271

272272
# Any minor breaks outside the dimensions need to be thrown away

tests/testthat/test-scales-breaks-labels.r

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,10 @@ test_that("only finite or NA values for breaks for transformed scales (#871)", {
248248
breaks <- sc$get_breaks()
249249
expect_true(all(is.finite(breaks) | is.na(breaks)))
250250
})
251+
252+
test_that("minor breaks are transformed by scales", {
253+
sc <- scale_y_continuous(limits = c(1, 100), trans = "log10",
254+
minor_breaks = c(1, 10, 100))
255+
256+
expect_equal(sc$get_breaks_minor(), c(0, 1, 2))
257+
})

0 commit comments

Comments
 (0)