44
44
# ' for `barwidth` and `barheight`.
45
45
# ' @param reverse logical. If `TRUE` the colorbar is reversed. By default,
46
46
# ' the highest value is on the top and the lowest value is on the bottom
47
+ # ' @param available_aes A vector of charater strings listing the aesthetics
48
+ # ' for which a colorbar can be drawn.
47
49
# ' @param ... ignored.
48
50
# ' @return A guide object
49
51
# ' @export
@@ -134,6 +136,7 @@ guide_colourbar <- function(
134
136
default.unit = " line" ,
135
137
reverse = FALSE ,
136
138
order = 0 ,
139
+ available_aes = c(" colour" , " color" , " fill" ),
137
140
138
141
... ) {
139
142
@@ -180,7 +183,9 @@ guide_colourbar <- function(
180
183
order = order ,
181
184
182
185
# parameter
183
- available_aes = c(" colour" , " color" , " fill" ), ... , name = " colorbar" ),
186
+ available_aes = available_aes ,
187
+ ... ,
188
+ name = " colorbar" ),
184
189
class = c(" guide" , " colorbar" )
185
190
)
186
191
}
@@ -189,8 +194,9 @@ guide_colourbar <- function(
189
194
guide_train.colorbar <- function (guide , scale ) {
190
195
191
196
# do nothing if scale are inappropriate
192
- if (length(intersect(scale $ aesthetics , c(" color" , " colour" , " fill" ))) == 0 ) {
193
- warning(" colorbar guide needs colour or fill scales." )
197
+ if (length(intersect(scale $ aesthetics , guide $ available_aes )) == 0 ) {
198
+ warning(" colorbar guide needs appropriate scales: " ,
199
+ paste(guide $ available_aes , collapse = " , " ))
194
200
return (NULL )
195
201
}
196
202
if (scale $ is_discrete()) {
0 commit comments