1
1
ScaleGradient <- proto(ScaleContinuous , expr = {
2
2
aliases <- c(" scale_colour_continuous" , " scale_fill_continuous" , " scale_color_continuous" , " scale_color_gradient" )
3
3
4
- new <- function (. , name = NULL , low = " #3B4FB8" , high = " #B71B1A" , space = " rgb" , breaks = NULL , labels = NULL , limits = NULL , trans = " identity" , legend = TRUE , ... , variable ) {
5
- if (is.character(trans )) trans <- Trans $ find(trans )
6
-
7
- b_and_l <- check_breaks_and_labels(breaks , labels )
8
-
9
- . $ proto(name = name , low = low , high = high , space = space , .input = variable , .output = variable , .tr = trans , limits = limits , breaks = b_and_l $ breaks , .labels = b_and_l $ labels , legend = legend , ... )
4
+ new <- function (. , name = NULL , low = " #3B4FB8" , high = " #B71B1A" , space = " rgb" , ... ) {
5
+
6
+ .super $ new(. , name = name , low = low , high = high , space = space , ... )
10
7
}
11
8
12
9
map <- function (. , x ) {
@@ -19,9 +16,6 @@ ScaleGradient <- proto(ScaleContinuous, expr={
19
16
nice_ramp(ramp , x )
20
17
}
21
18
22
- labels <- function (. ) {
23
- nulldefault(. $ .labels , . $ .tr $ label(. $ input_breaks()))
24
- }
25
19
output_breaks <- function (. ) {
26
20
. $ map(. $ input_breaks())
27
21
}
@@ -93,12 +87,9 @@ ScaleGradient <- proto(ScaleContinuous, expr={
93
87
})
94
88
95
89
ScaleGradient2 <- proto(ScaleContinuous , expr = {
96
- new <- function (. , name = NULL , low = muted(" red" ), mid = " white" , high = muted(" blue" ), midpoint = 0 , space = " rgb" , breaks = NULL , labels = NULL , limits = NULL , trans = " identity" , legend = TRUE , ... , variable ) {
97
- if (is.character(trans )) trans <- Trans $ find(trans )
98
-
99
- b_and_l <- check_breaks_and_labels(breaks , labels )
100
-
101
- . $ proto(name = name , low = low , mid = mid , high = high , midpoint = midpoint , space = space , ... , .input = variable , .output = variable , .tr = trans , limits = limits , breaks = b_and_l $ breaks , .labels = b_and_l $ labels , legend = legend )
90
+ new <- function (. , name = NULL , low = muted(" red" ), mid = " white" , high = muted(" blue" ), midpoint = 0 , space = " rgb" , ... ) {
91
+ .super $ new(. , name = name , low = low , mid = mid , high = high ,
92
+ midpoint = midpoint , space = space , ... )
102
93
}
103
94
104
95
aliases <- c(" scale_color_gradient2" )
@@ -122,9 +113,6 @@ ScaleGradient2 <- proto(ScaleContinuous, expr={
122
113
desc <- " Smooth gradient between three colours (high, low and midpoints)"
123
114
124
115
output_breaks <- function (. ) . $ map(. $ input_breaks())
125
- labels <- function (. ) {
126
- nulldefault(. $ .labels , . $ .tr $ label(. $ input_breaks()))
127
- }
128
116
129
117
icon <- function (. ) {
130
118
g <- scale_fill_gradient2()
@@ -191,19 +179,12 @@ ScaleGradient2 <- proto(ScaleContinuous, expr={
191
179
192
180
193
181
ScaleGradientn <- proto(ScaleContinuous , expr = {
194
- new <- function (. , name = NULL , colours , values = NULL , rescale = TRUE , space = " rgb" , breaks = NULL , labels = NULL , limits = NULL , trans = " identity" , legend = TRUE , ... , variable ) {
195
- if (is.character(trans )) trans <- Trans $ find(trans )
196
- if (! is.null(values )) limits <- range(values )
182
+ new <- function (. , name = NULL , colours , values = NULL , rescale = TRUE , space = " rgb" , ... ) {
197
183
198
- b_and_l <- check_breaks_and_labels(breaks , labels )
199
-
200
- . $ proto(
184
+ .super $ new(. ,
201
185
name = name ,
202
186
colours = colours , values = values , rescale = rescale ,
203
187
space = space , ... ,
204
- .input = variable , .output = variable , .tr = trans ,
205
- limits = limits , breaks = b_and_l $ breaks , .labels = b_and_l $ labels ,
206
- legend = legend
207
188
)
208
189
}
209
190
@@ -225,9 +206,6 @@ ScaleGradientn <- proto(ScaleContinuous, expr={
225
206
desc <- " Smooth gradient between n colours"
226
207
227
208
output_breaks <- function (. ) . $ map(. $ input_breaks())
228
- labels <- function (. ) {
229
- nulldefault(. $ .labels , . $ .tr $ label(. $ input_breaks()))
230
- }
231
209
232
210
icon <- function (. ) {
233
211
g <- scale_fill_gradientn(colours = rainbow(7 ))
0 commit comments