Skip to content

Commit a9afbab

Browse files
committed
Close #2357. In some cases, decor has min/max instead of value. In that case, treat max like value
1 parent 8e2c3fa commit a9afbab

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

R/ggplotly.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,7 @@ gdef2trace <- function(gdef, theme, gglayout) {
14211421
# N.B. ggplot2 >v3.4.2 (specifically #4879) renamed bar to decor and also
14221422
# started returning normalized values for the key field
14231423
decor <- gdef$decor %||% gdef$bar
1424+
decor$value <- decor$value %||% decor$max
14241425
rng <- range(decor$value)
14251426
decor$value <- scales::rescale(decor$value, from = rng)
14261427
if (!"decor" %in% names(gdef)) {

tests/testthat/test-ggplot-contour.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,15 @@ test_that("geom_contour is translated to a path", {
1212
expect_identical(L$data[[1]]$mode, "lines")
1313
})
1414

15-
15+
test_that("raster/contour works with scale_fill_binned", {
16+
xy_grid <- expand.grid(ps=seq(-1,3, length=100),
17+
trs=seq(-1,3,length=100))
18+
xy_grid$ptl <- xy_grid$ps^2 + xy_grid$trs^2
19+
20+
gg <- ggplot(xy_grid) +
21+
geom_raster(aes(y=ps,x=trs,fill=ptl), interpolate = TRUE) +
22+
geom_contour(aes(y=ps,x=trs,z=ptl), breaks = c(2,4,6,8,10), color='black') +
23+
scale_fill_binned(low = 'red', high = 'green', breaks = c(2,4,6,8,10))
24+
25+
expect_doppelganger_built(gg, "raster-contour-binned")
26+
})

0 commit comments

Comments
 (0)