@@ -463,40 +463,40 @@ Scale <- ggproto("Scale", NULL,
463
463
title
464
464
},
465
465
466
- new = function (self , aesthetics , palette , name = waiver() , breaks = waiver(),
466
+ new = function (self , aesthetics = NULL , breaks = waiver(),
467
467
minor_breaks = waiver(), labels = waiver(), limits = NULL ,
468
- expand = waiver(), guide = " legend " , position = " left " ,
468
+ guide = NULL , position = NULL ,
469
469
call = caller_call(), ... , super = NULL ) {
470
470
471
- call <- call %|| % current_call()
472
- aesthetics <- standardise_aes_names(aesthetics )
471
+ super <- super %|| % self
472
+ call <- call %|| % super $ call() %|| % current_call()
473
+ aesthetics <- standardise_aes_names(aesthetics %|| % super $ aesthetics )
474
+ limits <- allow_lambda(limits %|| % super $ limits )
475
+ breaks <- allow_lambda(breaks %| W | % super $ breaks )
476
+ labels <- allow_lambda(labels %| W | % super $ labels )
477
+ minor_breaks <- allow_lambda(minor_breaks %| W | % super $ minor_breaks )
473
478
check_breaks_labels(breaks , labels , call = call )
474
- limits <- allow_lambda(limits )
475
- breaks <- allow_lambda(breaks )
476
- labels <- allow_lambda(labels )
477
- minor_breaks <- allow_lambda(minor_breaks )
478
- position <- arg_match0(position , .trbl )
479
+ position <- arg_match0(position %|| % super $ position , .trbl )
479
480
if (is.null(breaks ) & all(! is_position_aes(aesthetics ))) {
480
481
guide <- " none"
481
482
}
482
483
483
- super <- super %|| % self
484
484
ggproto(
485
485
NULL , super ,
486
486
call = call ,
487
487
aesthetics = aesthetics ,
488
- palette = palette ,
489
488
limits = limits ,
490
- expand = expand ,
491
- name = name ,
492
489
breaks = breaks ,
493
490
minor_breaks = minor_breaks ,
494
491
labels = labels ,
495
- guide = guide ,
492
+ guide = guide % || % super $ guide ,
496
493
position = position ,
497
494
...
498
495
)
496
+ },
499
497
498
+ update = function (self , params ) {
499
+ inject(self $ new(!!! params ))
500
500
}
501
501
)
502
502
@@ -811,18 +811,19 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
811
811
}
812
812
},
813
813
814
- new = function (self , rescaler = rescale , oob = censor ,
814
+ new = function (self , rescaler = NULL , oob = NULL ,
815
815
range = ContinuousRange $ new(),
816
- transform = " identity " , limits = NULL , ... ,
816
+ transform = NULL , limits = NULL , ... ,
817
817
super = NULL ) {
818
-
819
- transform <- as.transform(transform )
820
- if (! is.null(limits ) && ! is.function(limits ) && ! is.formula(limits )) {
821
- limits = transform $ transform(limits )
818
+ super <- super %|| % self
819
+ transform <- as.transform(transform %|| % super $ trans )
820
+ limits <- allow_lambda(limits %|| % super $ limits )
821
+ if (! is.null(limits ) && ! is.function(limits )) {
822
+ limits <- transform $ transform(limits )
822
823
}
823
824
824
- rescaler <- allow_lambda(rescaler )
825
- oob <- allow_lambda(oob )
825
+ rescaler <- allow_lambda(rescaler % || % super $ rescaler )
826
+ oob <- allow_lambda(oob % || % super $ oob )
826
827
827
828
ggproto_parent(Scale , self )$ new(
828
829
rescaler = rescaler ,
@@ -831,8 +832,20 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
831
832
trans = transform ,
832
833
limits = limits ,
833
834
... ,
834
- super = super % || % self
835
+ super = super
835
836
)
837
+ },
838
+
839
+ update = function (self , params ) {
840
+ # We may need to update limits when previously transformed and
841
+ # a new transformation is coming in
842
+ if (" transform" %in% names(params ) &&
843
+ self $ trans $ name != " identity" &&
844
+ (! " limits" %in% names(params )) &&
845
+ ! is.null(self $ limits ) && ! is.function(self $ limits )) {
846
+ params $ limits <- self $ trans $ inverse(self $ limits )
847
+ }
848
+ inject(self $ new(!!! params ))
836
849
}
837
850
)
838
851
0 commit comments