Skip to content

Commit df35a7d

Browse files
authored
Handle geom_tile() with no fill aesthetic (#2063)
1 parent aa9dcb7 commit df35a7d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
## Bug fixes
99

1010
* `ggplotly()` now converts `stat_ecdf()` properly. (#2065)
11+
* `ggplotly()` now correctly handles `geom_tile()` with no `fill` aesthetic. (#2063)
12+
1113

1214
# 4.10.0
1315

R/layers2traces.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ to_basic.GeomRasterAnn <- function(data, prestats_data, layout, params, p, ...)
368368
#' @export
369369
to_basic.GeomTile <- function(data, prestats_data, layout, params, p, ...) {
370370
# geom2trace.GeomTile is a heatmap, which requires continuous fill
371-
if (is.discrete(prestats_data$fill)) {
371+
if (is.discrete(prestats_data$fill %||% NA_character_)) {
372372
data <- prefix_class(data, "GeomRect")
373373
to_basic(data, prestats_data, layout, params, p)
374374
} else {

tests/testthat/test-ggplot-heatmap.R

+9
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,12 @@ test_that("geom_tile() with discrete x/y", {
6363
expect_equivalent(L$data[[1]]$type, "heatmap")
6464
})
6565

66+
test_that("geom_tile() with no fill aesthetic", {
67+
df <- data.frame(
68+
x = rep(c(2, 5, 7, 9, 12), 2),
69+
y = rep(c(1, 2), each = 5)
70+
)
71+
p <- ggplot(df, aes(x, y)) + geom_tile(colour = "grey50")
72+
expect_doppelganger(ggplotly(p), "tile-no-fill")
73+
})
74+

0 commit comments

Comments
 (0)