Skip to content

Commit f0364cb

Browse files
committed
provide a default colorscale to histogram2dcontour
1 parent e0eca8f commit f0364cb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/plotly_build.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ map_size <- function(traces) {
411411
# appends a new (empty) trace to generate (plot-wide) colorbar/colorscale
412412
map_color <- function(traces, title = "", na.color = "transparent") {
413413
color <- lapply(traces, function(x) {
414-
x[["color"]] %||% if (identical("histogram2d", x[["type"]])) c(0, 1) else if (has_attr(x[["type"]], "colorscale")) x[["z"]] else NULL
414+
x[["color"]] %||% if (grepl("histogram2d", x[["type"]])) c(0, 1) else if (has_attr(x[["type"]], "colorscale")) x[["z"]] else NULL
415415
})
416416
isConstant <- vapply(color, function(x) inherits(x, "AsIs") || is.null(x), logical(1))
417417
isNumeric <- vapply(color, is.numeric, logical(1)) & !isConstant
@@ -427,7 +427,7 @@ map_color <- function(traces, title = "", na.color = "transparent") {
427427
hasText <- has_text(types, modes)
428428
hasZ <- has_attr(types, "colorscale") &
429429
any(vapply(traces, function(tr) {
430-
!is.null(tr[["z"]]) || identical("histogram2d", tr[["type"]])
430+
!is.null(tr[["z"]]) || grepl("histogram2d", tr[["type"]])
431431
}, logical(1)))
432432

433433
colorDefaults <- traceColorDefaults()
@@ -477,7 +477,7 @@ map_color <- function(traces, title = "", na.color = "transparent") {
477477
traces[[i]] <- modify_list(colorObj, traces[[i]])
478478
traces[[i]]$colorscale <- as_df(traces[[i]]$colorscale)
479479
# sigh, contour colorscale doesn't support alpha
480-
if (traces[[i]][["type"]] == "contour") {
480+
if (grepl("contour", traces[[i]][["type"]])) {
481481
traces[[i]]$colorscale[, 2] <- strip_alpha(traces[[i]]$colorscale[, 2])
482482
}
483483
traces[[i]] <- structure(traces[[i]], class = c("plotly_colorbar", "zcolor"))

0 commit comments

Comments
 (0)