@@ -413,7 +413,7 @@ map_size <- function(traces) {
413
413
# appends a new (empty) trace to generate (plot-wide) colorbar/colorscale
414
414
map_color <- function (traces , title = " " , na.color = " transparent" ) {
415
415
color <- lapply(traces , function (x ) {
416
- x [[" color" ]] %|| % if (has_attr(x $ type , " colorscale" )) x [[" z" ]] else NULL
416
+ x [[" color" ]] %|| % if (identical( " histogram2d " , x [[ " type " ]])) c( 0 , 1 ) else if ( has_attr(x [[ " type" ]] , " colorscale" )) x [[" z" ]] else NULL
417
417
})
418
418
isConstant <- vapply(color , function (x ) inherits(x , " AsIs" ) || is.null(x ), logical (1 ))
419
419
isNumeric <- vapply(color , is.numeric , logical (1 )) & ! isConstant
@@ -428,7 +428,9 @@ map_color <- function(traces, title = "", na.color = "transparent") {
428
428
hasLine <- has_line(types , modes )
429
429
hasText <- has_text(types , modes )
430
430
hasZ <- has_attr(types , " colorscale" ) &
431
- any(vapply(traces , function (tr ) ! is.null(tr $ z ), logical (1 )))
431
+ any(vapply(traces , function (tr ) {
432
+ ! is.null(tr [[" z" ]]) || identical(" histogram2d" , tr [[" type" ]])
433
+ }, logical (1 )))
432
434
433
435
colorDefaults <- traceColorDefaults()
434
436
for (i in which(isConstant )) {
0 commit comments