4444# ' for `barwidth` and `barheight`.
4545# ' @param reverse logical. If `TRUE` the colorbar is reversed. By default,
4646# ' 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.
4749# ' @param ... ignored.
4850# ' @return A guide object
4951# ' @export
@@ -134,6 +136,7 @@ guide_colourbar <- function(
134136 default.unit = " line" ,
135137 reverse = FALSE ,
136138 order = 0 ,
139+ available_aes = c(" colour" , " color" , " fill" ),
137140
138141 ... ) {
139142
@@ -180,7 +183,9 @@ guide_colourbar <- function(
180183 order = order ,
181184
182185 # parameter
183- available_aes = c(" colour" , " color" , " fill" ), ... , name = " colorbar" ),
186+ available_aes = available_aes ,
187+ ... ,
188+ name = " colorbar" ),
184189 class = c(" guide" , " colorbar" )
185190 )
186191}
@@ -189,8 +194,9 @@ guide_colourbar <- function(
189194guide_train.colorbar <- function (guide , scale ) {
190195
191196 # 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 = " , " ))
194200 return (NULL )
195201 }
196202 if (scale $ is_discrete()) {
0 commit comments