@@ -560,6 +560,17 @@ check_breaks_labels <- function(breaks, labels) {
560
560
TRUE
561
561
}
562
562
563
+ default_transform <- function (self , x ) {
564
+ new_x <- self $ trans $ transform(x )
565
+ axis <- if (" x" %in% self $ aesthetics ) " x" else " y"
566
+ check_transformation(x , new_x , self $ scale_name , axis )
567
+ new_x
568
+ }
569
+
570
+ has_default_transform <- function (scale ) {
571
+ transform_method <- environment(scale $ transform )$ f
572
+ identical(default_transform , transform_method ) || identical(identity , transform_method )
573
+ }
563
574
564
575
# ' @rdname ggplot2-ggproto
565
576
# ' @format NULL
@@ -589,12 +600,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
589
600
! has_data && ! has_limits
590
601
},
591
602
592
- transform = function (self , x ) {
593
- new_x <- self $ trans $ transform(x )
594
- axis <- if (" x" %in% self $ aesthetics ) " x" else " y"
595
- check_transformation(x , new_x , self $ scale_name , axis )
596
- new_x
597
- },
603
+ transform = default_transform ,
598
604
599
605
map = function (self , x , limits = self $ get_limits()) {
600
606
x <- self $ rescale(self $ oob(x , range = limits ), limits )
@@ -819,9 +825,7 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
819
825
self $ range $ train(x , drop = self $ drop , na.rm = ! self $ na.translate )
820
826
},
821
827
822
- transform = function (x ) {
823
- x
824
- },
828
+ transform = identity ,
825
829
826
830
map = function (self , x , limits = self $ get_limits()) {
827
831
n <- sum(! is.na(limits ))
@@ -1001,12 +1005,7 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
1001
1005
self $ range $ train(x )
1002
1006
},
1003
1007
1004
- transform = function (self , x ) {
1005
- new_x <- self $ trans $ transform(x )
1006
- axis <- if (" x" %in% self $ aesthetics ) " x" else " y"
1007
- check_transformation(x , new_x , self $ scale_name , axis )
1008
- new_x
1009
- },
1008
+ transform = default_transform ,
1010
1009
1011
1010
map = function (self , x , limits = self $ get_limits()) {
1012
1011
if (self $ after.stat ) {
0 commit comments