Skip to content

Commit

Permalink
Handle geom_tile() with no fill aesthetic (#2063)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert authored Nov 2, 2021
1 parent aa9dcb7 commit df35a7d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
## Bug fixes

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


# 4.10.0

Expand Down
2 changes: 1 addition & 1 deletion R/layers2traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ to_basic.GeomRasterAnn <- function(data, prestats_data, layout, params, p, ...)
#' @export
to_basic.GeomTile <- function(data, prestats_data, layout, params, p, ...) {
# geom2trace.GeomTile is a heatmap, which requires continuous fill
if (is.discrete(prestats_data$fill)) {
if (is.discrete(prestats_data$fill %||% NA_character_)) {
data <- prefix_class(data, "GeomRect")
to_basic(data, prestats_data, layout, params, p)
} else {
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-ggplot-heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,12 @@ test_that("geom_tile() with discrete x/y", {
expect_equivalent(L$data[[1]]$type, "heatmap")
})

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

0 comments on commit df35a7d

Please sign in to comment.