From e720a51317f1732979ba3cfff8ca2ce2c32dd23e Mon Sep 17 00:00:00 2001 From: Carson Date: Fri, 6 Oct 2023 17:54:23 -0500 Subject: [PATCH 01/12] Specify origin for numeric->date coercion in unit test --- tests/testthat/test-ggplot-lines.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-ggplot-lines.R b/tests/testthat/test-ggplot-lines.R index 055f6711ee..e70179612a 100644 --- a/tests/testthat/test-ggplot-lines.R +++ b/tests/testthat/test-ggplot-lines.R @@ -50,7 +50,7 @@ test_that("Milliseconds are preserved with dynamic ticks", { p <- ggplotly(gg, dynamicTicks = TRUE) j <- plotly_json(p, jsonedit = FALSE) t2 <- jsonlite::fromJSON(j)$data$x[[1]] %>% - as.POSIXct(format = "%Y-%m-%d %H:%M:%OS") + as.POSIXct(format = "%Y-%m-%d %H:%M:%OS", origin = "1970-01-01 00:00:00") expect_equal(as.numeric(mean(diff(t2))), 0.1, tolerance = 0.01) expect_doppelganger_built(p, "line-milliseconds") }) From 922bea41b366e41e6f8ddc3e91906316da1c204b Mon Sep 17 00:00:00 2001 From: Carson Date: Fri, 6 Oct 2023 17:55:31 -0500 Subject: [PATCH 02/12] Quick and dirty fix proposal for tidyverse/ggplot2#5428 --- R/ggplotly.R | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/R/ggplotly.R b/R/ggplotly.R index 8ac3cd7ed8..7239ad529d 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -1512,7 +1512,15 @@ scales_add_missing <- function(plot, aesthetics) { # towards ggproto methods attached to `plot$guides` # ------------------------------------------------------------------------- get_gdefs_ggproto <- function(scales, theme, plot, layers) { - guides <- plot$guides$setup(scales) + + # Proposed change to accomodate + # https://github.com/tidyverse/ggplot2/pull/5428 + # Ensure a 1:1 mapping between aesthetics and scales + aesthetics <- lapply(scales, `[[`, "aesthetics") + scales <- rep.int(scales, lengths(aesthetics)) + aesthetics <- unlist(aesthetics, recursive = FALSE, use.names = FALSE) + + guides <- plot$guides$setup(scales, aesthetics = aesthetics) guides$train(scales, theme$legend.direction, plot$labels) if (length(guides$guides) > 0) { guides$merge() From 13b8fecd5946344c96afb624aabbfa2d1af15549 Mon Sep 17 00:00:00 2001 From: Carson Date: Fri, 6 Oct 2023 17:56:07 -0500 Subject: [PATCH 03/12] Quick and dirty fix proposal for tidyverse/ggplot2#5343 --- R/ggplotly.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/ggplotly.R b/R/ggplotly.R index 7239ad529d..fe146641d4 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -725,11 +725,13 @@ gg2list <- function(p, width = NULL, height = NULL, call. = FALSE ) } - # determine axis types (note: scale_name may go away someday) + # determine axis types (note: scale_name went away in ggplot2 v3.4.3) # https://github.com/hadley/ggplot2/issues/1312 - isDate <- isTRUE(sc$scale_name %in% c("date", "datetime")) + isDate <- isTRUE(sc$scale_name %in% c("date", "datetime")) || + inherits(sc, c("ScaleContinuousDatetime", "ScaleContinuousDate")) isDateType <- isDynamic && isDate - isDiscrete <- identical(sc$scale_name, "position_d") + isDiscrete <- identical(sc$scale_name, "position_d") || + inherits(sc, "ScaleDiscretePosition") isDiscreteType <- isDynamic && isDiscrete # In 3.2.x .major disappeared in favor of break_positions() From 6cdcfc96050986cbbe16a065a0f5abe8f354ec5d Mon Sep 17 00:00:00 2001 From: Carson Date: Sat, 7 Oct 2023 10:45:10 -0500 Subject: [PATCH 04/12] Update snapshots --- .../tests/shinytest/mytest-expected/001.json | 144 +++++++++--------- .../tests/shinytest/mytest-expected/002.json | 144 +++++++++--------- .../tests/shinytest/mytest-expected/003.json | 144 +++++++++--------- .../tests/shinytest/mytest-expected/004.json | 144 +++++++++--------- .../_snaps/ggplot-area/area-traces-order.svg | 2 +- .../_snaps/ggplot-labels/factor-labels.svg | 2 +- .../plotly-subplot-plot-list.svg | 2 +- 7 files changed, 291 insertions(+), 291 deletions(-) diff --git a/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/001.json b/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/001.json index 175aa7b1a3..0a80458075 100644 --- a/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/001.json +++ b/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/001.json @@ -14,70 +14,70 @@ "x": [ 21, 21, - 22.8, - 21.4, - 18.7, - 18.1, - 14.3, - 24.4, - 22.8, - 19.2, - 17.8, - 16.4, - 17.3, - 15.2, + 22.800000000000001, + 21.399999999999999, + 18.699999999999999, + 18.100000000000001, + 14.300000000000001, + 24.399999999999999, + 22.800000000000001, + 19.199999999999999, + 17.800000000000001, + 16.399999999999999, + 17.300000000000001, + 15.199999999999999, 10.4, 10.4, - 14.7, - 32.4, - 30.4, - 33.9, + 14.699999999999999, + 32.399999999999999, + 30.399999999999999, + 33.899999999999999, 21.5, 15.5, - 15.2, - 13.3, - 19.2, - 27.3, + 15.199999999999999, + 13.300000000000001, + 19.199999999999999, + 27.300000000000001, 26, - 30.4, - 15.8, - 19.7, + 30.399999999999999, + 15.800000000000001, + 19.699999999999999, 15, - 21.4 + 21.399999999999999 ], "y": [ - 2.62, + 2.6200000000000001, 2.875, - 2.32, - 3.215, - 3.44, + 2.3199999999999998, + 3.2149999999999999, + 3.4399999999999999, 3.46, - 3.57, - 3.19, - 3.15, - 3.44, - 3.44, - 4.07, + 3.5699999999999998, + 3.1899999999999999, + 3.1499999999999999, + 3.4399999999999999, + 3.4399999999999999, + 4.0700000000000003, 3.73, - 3.78, + 3.7799999999999998, 5.25, - 5.424, - 5.345, - 2.2, + 5.4240000000000004, + 5.3449999999999998, + 2.2000000000000002, 1.615, 1.835, - 2.465, + 2.4649999999999999, 3.52, - 3.435, - 3.84, - 3.845, - 1.935, - 2.14, - 1.513, - 3.17, + 3.4350000000000001, + 3.8399999999999999, + 3.8450000000000002, + 1.9350000000000001, + 2.1400000000000001, + 1.5129999999999999, + 3.1699999999999999, 2.77, - 3.57, - 2.78 + 3.5699999999999998, + 2.7799999999999998 ], "text": [ "mpg: 21.0
wt: 2.620
nms: Mazda RX4", @@ -153,10 +153,10 @@ "autocolorscale": false, "color": "rgba(0,0,0,1)", "opacity": 1, - "size": 5.66929133858268, + "size": 5.6692913385826778, "symbol": "circle", "line": { - "width": 1.88976377952756, + "width": 1.8897637795275593, "color": "rgba(0,0,0,1)" } }, @@ -170,17 +170,17 @@ ], "layout": { "margin": { - "t": 25.7412480974125, - "r": 7.30593607305936, - "b": 39.6955859969559, - "l": 31.4155251141553 + "t": 25.74124809741248, + "r": 7.3059360730593621, + "b": 39.69558599695587, + "l": 31.415525114155255 }, "plot_bgcolor": "rgba(235,235,235,1)", "paper_bgcolor": "rgba(255,255,255,1)", "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 }, "xaxis": { "domain": [ @@ -191,8 +191,8 @@ "type": "linear", "autorange": false, "range": [ - 9.225, - 35.075 + 9.2249999999999996, + 35.074999999999996 ], "tickmode": "array", "ticktext": [ @@ -223,13 +223,13 @@ "nticks": null, "ticks": "outside", "tickcolor": "rgba(51,51,51,1)", - "ticklen": 3.65296803652968, - "tickwidth": 0.66417600664176, + "ticklen": 3.6529680365296811, + "tickwidth": 0.66417600664176002, "showticklabels": true, "tickfont": { "color": "rgba(77,77,77,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 }, "tickangle": 0, "showline": false, @@ -237,7 +237,7 @@ "linewidth": 0, "showgrid": true, "gridcolor": "rgba(255,255,255,1)", - "gridwidth": 0.66417600664176, + "gridwidth": 0.66417600664176002, "zeroline": false, "anchor": "y", "title": { @@ -245,7 +245,7 @@ "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 } }, "hoverformat": ".2f" @@ -259,8 +259,8 @@ "type": "linear", "autorange": false, "range": [ - 1.31745, - 5.61955 + 1.3174499999999998, + 5.6195500000000003 ], "tickmode": "array", "ticktext": [ @@ -285,13 +285,13 @@ "nticks": null, "ticks": "outside", "tickcolor": "rgba(51,51,51,1)", - "ticklen": 3.65296803652968, - "tickwidth": 0.66417600664176, + "ticklen": 3.6529680365296811, + "tickwidth": 0.66417600664176002, "showticklabels": true, "tickfont": { "color": "rgba(77,77,77,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 }, "tickangle": 0, "showline": false, @@ -299,7 +299,7 @@ "linewidth": 0, "showgrid": true, "gridcolor": "rgba(255,255,255,1)", - "gridwidth": 0.66417600664176, + "gridwidth": 0.66417600664176002, "zeroline": false, "anchor": "x", "title": { @@ -307,7 +307,7 @@ "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 } }, "hoverformat": ".2f" @@ -335,11 +335,11 @@ "legend": { "bgcolor": "rgba(255,255,255,1)", "bordercolor": "transparent", - "borderwidth": 1.88976377952756, + "borderwidth": 1.8897637795275593, "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 } }, "hovermode": "closest", @@ -374,7 +374,7 @@ "persistent": false, "dynamic": false, "selectize": false, - "opacityDim": 0.2, + "opacityDim": 0.20000000000000001, "selected": { "opacity": 1 }, diff --git a/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/002.json b/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/002.json index 5025798b36..52807af51f 100644 --- a/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/002.json +++ b/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/002.json @@ -32,70 +32,70 @@ "x": [ 21, 21, - 22.8, - 21.4, - 18.7, - 18.1, - 14.3, - 24.4, - 22.8, - 19.2, - 17.8, - 16.4, - 17.3, - 15.2, + 22.800000000000001, + 21.399999999999999, + 18.699999999999999, + 18.100000000000001, + 14.300000000000001, + 24.399999999999999, + 22.800000000000001, + 19.199999999999999, + 17.800000000000001, + 16.399999999999999, + 17.300000000000001, + 15.199999999999999, 10.4, 10.4, - 14.7, - 32.4, - 30.4, - 33.9, + 14.699999999999999, + 32.399999999999999, + 30.399999999999999, + 33.899999999999999, 21.5, 15.5, - 15.2, - 13.3, - 19.2, - 27.3, + 15.199999999999999, + 13.300000000000001, + 19.199999999999999, + 27.300000000000001, 26, - 30.4, - 15.8, - 19.7, + 30.399999999999999, + 15.800000000000001, + 19.699999999999999, 15, - 21.4 + 21.399999999999999 ], "y": [ - 2.62, + 2.6200000000000001, 2.875, - 2.32, - 3.215, - 3.44, + 2.3199999999999998, + 3.2149999999999999, + 3.4399999999999999, 3.46, - 3.57, - 3.19, - 3.15, - 3.44, - 3.44, - 4.07, + 3.5699999999999998, + 3.1899999999999999, + 3.1499999999999999, + 3.4399999999999999, + 3.4399999999999999, + 4.0700000000000003, 3.73, - 3.78, + 3.7799999999999998, 5.25, - 5.424, - 5.345, - 2.2, + 5.4240000000000004, + 5.3449999999999998, + 2.2000000000000002, 1.615, 1.835, - 2.465, + 2.4649999999999999, 3.52, - 3.435, - 3.84, - 3.845, - 1.935, - 2.14, - 1.513, - 3.17, + 3.4350000000000001, + 3.8399999999999999, + 3.8450000000000002, + 1.9350000000000001, + 2.1400000000000001, + 1.5129999999999999, + 3.1699999999999999, 2.77, - 3.57, - 2.78 + 3.5699999999999998, + 2.7799999999999998 ], "text": [ "mpg: 21.0
wt: 2.620
nms: Mazda RX4", @@ -171,10 +171,10 @@ "autocolorscale": false, "color": "rgba(0,0,0,1)", "opacity": 1, - "size": 5.66929133858268, + "size": 5.6692913385826778, "symbol": "circle", "line": { - "width": 1.88976377952756, + "width": 1.8897637795275593, "color": "rgba(0,0,0,1)" } }, @@ -188,17 +188,17 @@ ], "layout": { "margin": { - "t": 25.7412480974125, - "r": 7.30593607305936, - "b": 39.6955859969559, - "l": 31.4155251141553 + "t": 25.74124809741248, + "r": 7.3059360730593621, + "b": 39.69558599695587, + "l": 31.415525114155255 }, "plot_bgcolor": "rgba(235,235,235,1)", "paper_bgcolor": "rgba(255,255,255,1)", "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 }, "xaxis": { "domain": [ @@ -209,8 +209,8 @@ "type": "linear", "autorange": false, "range": [ - 9.225, - 35.075 + 9.2249999999999996, + 35.074999999999996 ], "tickmode": "array", "ticktext": [ @@ -241,13 +241,13 @@ "nticks": null, "ticks": "outside", "tickcolor": "rgba(51,51,51,1)", - "ticklen": 3.65296803652968, - "tickwidth": 0.66417600664176, + "ticklen": 3.6529680365296811, + "tickwidth": 0.66417600664176002, "showticklabels": true, "tickfont": { "color": "rgba(77,77,77,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 }, "tickangle": 0, "showline": false, @@ -255,7 +255,7 @@ "linewidth": 0, "showgrid": true, "gridcolor": "rgba(255,255,255,1)", - "gridwidth": 0.66417600664176, + "gridwidth": 0.66417600664176002, "zeroline": false, "anchor": "y", "title": { @@ -263,7 +263,7 @@ "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 } }, "hoverformat": ".2f" @@ -277,8 +277,8 @@ "type": "linear", "autorange": false, "range": [ - 1.31745, - 5.61955 + 1.3174499999999998, + 5.6195500000000003 ], "tickmode": "array", "ticktext": [ @@ -303,13 +303,13 @@ "nticks": null, "ticks": "outside", "tickcolor": "rgba(51,51,51,1)", - "ticklen": 3.65296803652968, - "tickwidth": 0.66417600664176, + "ticklen": 3.6529680365296811, + "tickwidth": 0.66417600664176002, "showticklabels": true, "tickfont": { "color": "rgba(77,77,77,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 }, "tickangle": 0, "showline": false, @@ -317,7 +317,7 @@ "linewidth": 0, "showgrid": true, "gridcolor": "rgba(255,255,255,1)", - "gridwidth": 0.66417600664176, + "gridwidth": 0.66417600664176002, "zeroline": false, "anchor": "x", "title": { @@ -325,7 +325,7 @@ "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 } }, "hoverformat": ".2f" @@ -353,11 +353,11 @@ "legend": { "bgcolor": "rgba(255,255,255,1)", "bordercolor": "transparent", - "borderwidth": 1.88976377952756, + "borderwidth": 1.8897637795275593, "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 } }, "hovermode": "closest", @@ -392,7 +392,7 @@ "persistent": false, "dynamic": false, "selectize": false, - "opacityDim": 0.2, + "opacityDim": 0.20000000000000001, "selected": { "opacity": 1 }, diff --git a/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/003.json b/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/003.json index 17a3bbfe4b..069ced6f20 100644 --- a/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/003.json +++ b/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/003.json @@ -36,70 +36,70 @@ "x": [ 21, 21, - 22.8, - 21.4, - 18.7, - 18.1, - 14.3, - 24.4, - 22.8, - 19.2, - 17.8, - 16.4, - 17.3, - 15.2, + 22.800000000000001, + 21.399999999999999, + 18.699999999999999, + 18.100000000000001, + 14.300000000000001, + 24.399999999999999, + 22.800000000000001, + 19.199999999999999, + 17.800000000000001, + 16.399999999999999, + 17.300000000000001, + 15.199999999999999, 10.4, 10.4, - 14.7, - 32.4, - 30.4, - 33.9, + 14.699999999999999, + 32.399999999999999, + 30.399999999999999, + 33.899999999999999, 21.5, 15.5, - 15.2, - 13.3, - 19.2, - 27.3, + 15.199999999999999, + 13.300000000000001, + 19.199999999999999, + 27.300000000000001, 26, - 30.4, - 15.8, - 19.7, + 30.399999999999999, + 15.800000000000001, + 19.699999999999999, 15, - 21.4 + 21.399999999999999 ], "y": [ - 2.62, + 2.6200000000000001, 2.875, - 2.32, - 3.215, - 3.44, + 2.3199999999999998, + 3.2149999999999999, + 3.4399999999999999, 3.46, - 3.57, - 3.19, - 3.15, - 3.44, - 3.44, - 4.07, + 3.5699999999999998, + 3.1899999999999999, + 3.1499999999999999, + 3.4399999999999999, + 3.4399999999999999, + 4.0700000000000003, 3.73, - 3.78, + 3.7799999999999998, 5.25, - 5.424, - 5.345, - 2.2, + 5.4240000000000004, + 5.3449999999999998, + 2.2000000000000002, 1.615, 1.835, - 2.465, + 2.4649999999999999, 3.52, - 3.435, - 3.84, - 3.845, - 1.935, - 2.14, - 1.513, - 3.17, + 3.4350000000000001, + 3.8399999999999999, + 3.8450000000000002, + 1.9350000000000001, + 2.1400000000000001, + 1.5129999999999999, + 3.1699999999999999, 2.77, - 3.57, - 2.78 + 3.5699999999999998, + 2.7799999999999998 ], "text": [ "mpg: 21.0
wt: 2.620
nms: Mazda RX4", @@ -175,10 +175,10 @@ "autocolorscale": false, "color": "rgba(0,0,0,1)", "opacity": 1, - "size": 5.66929133858268, + "size": 5.6692913385826778, "symbol": "circle", "line": { - "width": 1.88976377952756, + "width": 1.8897637795275593, "color": "rgba(0,0,0,1)" } }, @@ -192,17 +192,17 @@ ], "layout": { "margin": { - "t": 25.7412480974125, - "r": 7.30593607305936, - "b": 39.6955859969559, - "l": 31.4155251141553 + "t": 25.74124809741248, + "r": 7.3059360730593621, + "b": 39.69558599695587, + "l": 31.415525114155255 }, "plot_bgcolor": "rgba(235,235,235,1)", "paper_bgcolor": "rgba(255,255,255,1)", "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 }, "xaxis": { "domain": [ @@ -213,8 +213,8 @@ "type": "linear", "autorange": false, "range": [ - 9.225, - 35.075 + 9.2249999999999996, + 35.074999999999996 ], "tickmode": "array", "ticktext": [ @@ -245,13 +245,13 @@ "nticks": null, "ticks": "outside", "tickcolor": "rgba(51,51,51,1)", - "ticklen": 3.65296803652968, - "tickwidth": 0.66417600664176, + "ticklen": 3.6529680365296811, + "tickwidth": 0.66417600664176002, "showticklabels": true, "tickfont": { "color": "rgba(77,77,77,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 }, "tickangle": 0, "showline": false, @@ -259,7 +259,7 @@ "linewidth": 0, "showgrid": true, "gridcolor": "rgba(255,255,255,1)", - "gridwidth": 0.66417600664176, + "gridwidth": 0.66417600664176002, "zeroline": false, "anchor": "y", "title": { @@ -267,7 +267,7 @@ "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 } }, "hoverformat": ".2f" @@ -281,8 +281,8 @@ "type": "linear", "autorange": false, "range": [ - 1.31745, - 5.61955 + 1.3174499999999998, + 5.6195500000000003 ], "tickmode": "array", "ticktext": [ @@ -307,13 +307,13 @@ "nticks": null, "ticks": "outside", "tickcolor": "rgba(51,51,51,1)", - "ticklen": 3.65296803652968, - "tickwidth": 0.66417600664176, + "ticklen": 3.6529680365296811, + "tickwidth": 0.66417600664176002, "showticklabels": true, "tickfont": { "color": "rgba(77,77,77,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 }, "tickangle": 0, "showline": false, @@ -321,7 +321,7 @@ "linewidth": 0, "showgrid": true, "gridcolor": "rgba(255,255,255,1)", - "gridwidth": 0.66417600664176, + "gridwidth": 0.66417600664176002, "zeroline": false, "anchor": "x", "title": { @@ -329,7 +329,7 @@ "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 } }, "hoverformat": ".2f" @@ -357,11 +357,11 @@ "legend": { "bgcolor": "rgba(255,255,255,1)", "bordercolor": "transparent", - "borderwidth": 1.88976377952756, + "borderwidth": 1.8897637795275593, "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 } }, "hovermode": "closest", @@ -396,7 +396,7 @@ "persistent": false, "dynamic": false, "selectize": false, - "opacityDim": 0.2, + "opacityDim": 0.20000000000000001, "selected": { "opacity": 1 }, diff --git a/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/004.json b/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/004.json index 2fce4cb389..2b72add64b 100644 --- a/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/004.json +++ b/inst/examples/shiny/event_data/tests/shinytest/mytest-expected/004.json @@ -37,70 +37,70 @@ "x": [ 21, 21, - 22.8, - 21.4, - 18.7, - 18.1, - 14.3, - 24.4, - 22.8, - 19.2, - 17.8, - 16.4, - 17.3, - 15.2, + 22.800000000000001, + 21.399999999999999, + 18.699999999999999, + 18.100000000000001, + 14.300000000000001, + 24.399999999999999, + 22.800000000000001, + 19.199999999999999, + 17.800000000000001, + 16.399999999999999, + 17.300000000000001, + 15.199999999999999, 10.4, 10.4, - 14.7, - 32.4, - 30.4, - 33.9, + 14.699999999999999, + 32.399999999999999, + 30.399999999999999, + 33.899999999999999, 21.5, 15.5, - 15.2, - 13.3, - 19.2, - 27.3, + 15.199999999999999, + 13.300000000000001, + 19.199999999999999, + 27.300000000000001, 26, - 30.4, - 15.8, - 19.7, + 30.399999999999999, + 15.800000000000001, + 19.699999999999999, 15, - 21.4 + 21.399999999999999 ], "y": [ - 2.62, + 2.6200000000000001, 2.875, - 2.32, - 3.215, - 3.44, + 2.3199999999999998, + 3.2149999999999999, + 3.4399999999999999, 3.46, - 3.57, - 3.19, - 3.15, - 3.44, - 3.44, - 4.07, + 3.5699999999999998, + 3.1899999999999999, + 3.1499999999999999, + 3.4399999999999999, + 3.4399999999999999, + 4.0700000000000003, 3.73, - 3.78, + 3.7799999999999998, 5.25, - 5.424, - 5.345, - 2.2, + 5.4240000000000004, + 5.3449999999999998, + 2.2000000000000002, 1.615, 1.835, - 2.465, + 2.4649999999999999, 3.52, - 3.435, - 3.84, - 3.845, - 1.935, - 2.14, - 1.513, - 3.17, + 3.4350000000000001, + 3.8399999999999999, + 3.8450000000000002, + 1.9350000000000001, + 2.1400000000000001, + 1.5129999999999999, + 3.1699999999999999, 2.77, - 3.57, - 2.78 + 3.5699999999999998, + 2.7799999999999998 ], "text": [ "mpg: 21.0
wt: 2.620
nms: Mazda RX4", @@ -176,10 +176,10 @@ "autocolorscale": false, "color": "rgba(0,0,0,1)", "opacity": 1, - "size": 5.66929133858268, + "size": 5.6692913385826778, "symbol": "circle", "line": { - "width": 1.88976377952756, + "width": 1.8897637795275593, "color": "rgba(0,0,0,1)" } }, @@ -193,17 +193,17 @@ ], "layout": { "margin": { - "t": 25.7412480974125, - "r": 7.30593607305936, - "b": 39.6955859969559, - "l": 31.4155251141553 + "t": 25.74124809741248, + "r": 7.3059360730593621, + "b": 39.69558599695587, + "l": 31.415525114155255 }, "plot_bgcolor": "rgba(235,235,235,1)", "paper_bgcolor": "rgba(255,255,255,1)", "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 }, "xaxis": { "domain": [ @@ -214,8 +214,8 @@ "type": "linear", "autorange": false, "range": [ - 9.225, - 35.075 + 9.2249999999999996, + 35.074999999999996 ], "tickmode": "array", "ticktext": [ @@ -246,13 +246,13 @@ "nticks": null, "ticks": "outside", "tickcolor": "rgba(51,51,51,1)", - "ticklen": 3.65296803652968, - "tickwidth": 0.66417600664176, + "ticklen": 3.6529680365296811, + "tickwidth": 0.66417600664176002, "showticklabels": true, "tickfont": { "color": "rgba(77,77,77,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 }, "tickangle": 0, "showline": false, @@ -260,7 +260,7 @@ "linewidth": 0, "showgrid": true, "gridcolor": "rgba(255,255,255,1)", - "gridwidth": 0.66417600664176, + "gridwidth": 0.66417600664176002, "zeroline": false, "anchor": "y", "title": { @@ -268,7 +268,7 @@ "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 } }, "hoverformat": ".2f" @@ -282,8 +282,8 @@ "type": "linear", "autorange": false, "range": [ - 1.31745, - 5.61955 + 1.3174499999999998, + 5.6195500000000003 ], "tickmode": "array", "ticktext": [ @@ -308,13 +308,13 @@ "nticks": null, "ticks": "outside", "tickcolor": "rgba(51,51,51,1)", - "ticklen": 3.65296803652968, - "tickwidth": 0.66417600664176, + "ticklen": 3.6529680365296811, + "tickwidth": 0.66417600664176002, "showticklabels": true, "tickfont": { "color": "rgba(77,77,77,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 }, "tickangle": 0, "showline": false, @@ -322,7 +322,7 @@ "linewidth": 0, "showgrid": true, "gridcolor": "rgba(255,255,255,1)", - "gridwidth": 0.66417600664176, + "gridwidth": 0.66417600664176002, "zeroline": false, "anchor": "x", "title": { @@ -330,7 +330,7 @@ "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 14.6118721461187 + "size": 14.611872146118724 } }, "hoverformat": ".2f" @@ -358,11 +358,11 @@ "legend": { "bgcolor": "rgba(255,255,255,1)", "bordercolor": "transparent", - "borderwidth": 1.88976377952756, + "borderwidth": 1.8897637795275593, "font": { "color": "rgba(0,0,0,1)", "family": "", - "size": 11.689497716895 + "size": 11.68949771689498 } }, "hovermode": "closest", @@ -397,7 +397,7 @@ "persistent": false, "dynamic": false, "selectize": false, - "opacityDim": 0.2, + "opacityDim": 0.20000000000000001, "selected": { "opacity": 1 }, diff --git a/tests/testthat/_snaps/ggplot-area/area-traces-order.svg b/tests/testthat/_snaps/ggplot-area/area-traces-order.svg index 48426b9a11..d1e4cbe457 100644 --- a/tests/testthat/_snaps/ggplot-area/area-traces-order.svg +++ b/tests/testthat/_snaps/ggplot-area/area-traces-order.svg @@ -1 +1 @@ -0123450.000.250.500.751.00cutFairGoodVery GoodPremiumIdealcaratfreq +0123450.000.250.500.751.00cutFairGoodVery GoodPremiumIdealcaratfreq diff --git a/tests/testthat/_snaps/ggplot-labels/factor-labels.svg b/tests/testthat/_snaps/ggplot-labels/factor-labels.svg index eecef86a59..53f11d16c8 100644 --- a/tests/testthat/_snaps/ggplot-labels/factor-labels.svg +++ b/tests/testthat/_snaps/ggplot-labels/factor-labels.svg @@ -1 +1 @@ -abcde05000100001500020000Cutcount +abcde05000100001500020000cutcount diff --git a/tests/testthat/_snaps/plotly-subplot/plotly-subplot-plot-list.svg b/tests/testthat/_snaps/plotly-subplot/plotly-subplot-plot-list.svg index 9d2ffb8e85..f3142fa13b 100644 --- a/tests/testthat/_snaps/plotly-subplot/plotly-subplot-plot-list.svg +++ b/tests/testthat/_snaps/plotly-subplot/plotly-subplot-plot-list.svg @@ -1 +1 @@ -05k10k200k250k300k510151020197019801990200020105k10k15kpcepoppsavertuempmedunemploy +05k10k200k250k300k510151020197019801990200020105k10k15kpcepoppsavertuempmedunemploy From 03ef5e23fa241084916a63f97f4d62d09034dbb0 Mon Sep 17 00:00:00 2001 From: Carson Date: Sat, 7 Oct 2023 11:38:23 -0500 Subject: [PATCH 05/12] Use dev version of Gally during check --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index be477e0a60..e788b831e1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -82,6 +82,7 @@ Encoding: UTF-8 Roxygen: list(markdown = TRUE) Config/Needs/check: tidyverse/ggplot2, + ggobi/ggally, rcmdcheck, devtools, reshape2 From caa97c83c76889a1dd7252bea14c2106dfbbcb29 Mon Sep 17 00:00:00 2001 From: Carson Date: Sat, 7 Oct 2023 11:45:51 -0500 Subject: [PATCH 06/12] Don't use pak to install dev GGally --- .github/workflows/R-CMD-check.yaml | 5 +++++ DESCRIPTION | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 275487bf57..4a4f1cfd5f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -61,6 +61,11 @@ jobs: with: cache-version: 3 needs: check + + - name: Install dev GGally + run: | + Rscript -e "if (!require('remotes')) install.packages('remotes')" + Rscript -e "remotes::install_github('ggobi/ggally')" - name: Set up Python 3.8 uses: actions/setup-python@v2 diff --git a/DESCRIPTION b/DESCRIPTION index e788b831e1..be477e0a60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -82,7 +82,6 @@ Encoding: UTF-8 Roxygen: list(markdown = TRUE) Config/Needs/check: tidyverse/ggplot2, - ggobi/ggally, rcmdcheck, devtools, reshape2 From 73d7e1bea63e5382417f66e25dabf632ffa14e86 Mon Sep 17 00:00:00 2001 From: Carson Date: Sat, 7 Oct 2023 11:48:01 -0500 Subject: [PATCH 07/12] Use a proper shell context --- .github/workflows/R-CMD-check.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 4a4f1cfd5f..2096b51e70 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -63,9 +63,10 @@ jobs: needs: check - name: Install dev GGally + shell: Rscript {0} run: | - Rscript -e "if (!require('remotes')) install.packages('remotes')" - Rscript -e "remotes::install_github('ggobi/ggally')" + if (!require('remotes')) install.packages('remotes') + remotes::install_github('ggobi/ggally') - name: Set up Python 3.8 uses: actions/setup-python@v2 From 7f2d96f5a1302c2b3c49687cdeac3f89e1cd547f Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 10 Oct 2023 15:10:44 -0500 Subject: [PATCH 08/12] Simplify scale type detection logic (since new approach works with old versions; use it across the board) --- R/ggplotly.R | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/R/ggplotly.R b/R/ggplotly.R index fe146641d4..da452d3044 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -725,13 +725,11 @@ gg2list <- function(p, width = NULL, height = NULL, call. = FALSE ) } - # determine axis types (note: scale_name went away in ggplot2 v3.4.3) - # https://github.com/hadley/ggplot2/issues/1312 - isDate <- isTRUE(sc$scale_name %in% c("date", "datetime")) || - inherits(sc, c("ScaleContinuousDatetime", "ScaleContinuousDate")) + + # determine axis types + isDate <- inherits(sc, c("ScaleContinuousDatetime", "ScaleContinuousDate")) isDateType <- isDynamic && isDate - isDiscrete <- identical(sc$scale_name, "position_d") || - inherits(sc, "ScaleDiscretePosition") + isDiscrete <- inherits(sc, "ScaleDiscretePosition") isDiscreteType <- isDynamic && isDiscrete # In 3.2.x .major disappeared in favor of break_positions() From 921b9b59b98cd7c37f9d08e18e123d59bb850df0 Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 10 Oct 2023 16:18:04 -0500 Subject: [PATCH 09/12] Dev version GGally doesn't do anything to fix the issues dev ggplot2 has introduced --- .github/workflows/R-CMD-check.yaml | 6 ------ R/ggplotly.R | 5 ++--- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 2096b51e70..275487bf57 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -61,12 +61,6 @@ jobs: with: cache-version: 3 needs: check - - - name: Install dev GGally - shell: Rscript {0} - run: | - if (!require('remotes')) install.packages('remotes') - remotes::install_github('ggobi/ggally') - name: Set up Python 3.8 uses: actions/setup-python@v2 diff --git a/R/ggplotly.R b/R/ggplotly.R index da452d3044..e6805169a2 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -1513,9 +1513,8 @@ scales_add_missing <- function(plot, aesthetics) { # ------------------------------------------------------------------------- get_gdefs_ggproto <- function(scales, theme, plot, layers) { - # Proposed change to accomodate - # https://github.com/tidyverse/ggplot2/pull/5428 - # Ensure a 1:1 mapping between aesthetics and scales + # Unfortunate duplication of logic in tidyverse/ggplot2#5428 + # which ensures a 1:1 mapping between aesthetics and scales aesthetics <- lapply(scales, `[[`, "aesthetics") scales <- rep.int(scales, lengths(aesthetics)) aesthetics <- unlist(aesthetics, recursive = FALSE, use.names = FALSE) From 36fe752167ac300b7109b1e8022dfa2d369ac61c Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 10 Oct 2023 16:24:09 -0500 Subject: [PATCH 10/12] Be more careful to support discrete scales that contain a vector of aesthetics --- R/layers2traces.R | 3 ++- tests/testthat/test-ggplot-legend.R | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/R/layers2traces.R b/R/layers2traces.R index 77244a6e54..240087563f 100644 --- a/R/layers2traces.R +++ b/R/layers2traces.R @@ -79,7 +79,8 @@ layers2traces <- function(data, prestats_data, layout, p) { discreteScales <- list() for (sc in p$scales$non_position_scales()$scales) { if (sc$is_discrete()) { - discreteScales[[sc$aesthetics]] <- sc + nm <- paste(sc$aesthetics, collapse = "_") + discreteScales[[nm]] <- sc } } # Convert "high-level" geoms to their "low-level" counterpart diff --git a/tests/testthat/test-ggplot-legend.R b/tests/testthat/test-ggplot-legend.R index d4dfe4eed2..9dd92ea96c 100644 --- a/tests/testthat/test-ggplot-legend.R +++ b/tests/testthat/test-ggplot-legend.R @@ -148,3 +148,17 @@ test_that("many legend items", { p <- ggplot(midwest, aes(category, fill = category)) + geom_bar() info <- expect_traces(p, length(unique(midwest$category)), "many legend items") }) + + +# Make sure we can support the bugfix made in tidyverse/ggplot2#5425 +test_that("can handle varying aesthetics/scales", { + df <- data.frame(x = (1:3)/3, z = c("red", "blue", "green")) + + p <- ggplot(df) + + aes(x, z, colour = z, fill = z, size = x) + + geom_point() + + scale_discrete_identity(aesthetics = c("colour", "fill")) + + scale_size_identity() + + expect_traces(p, 1, "varying-aes-guide") +}) From 4707a8e59d75f76c6b743663060706a3be5843ee Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 10 Oct 2023 19:34:10 -0500 Subject: [PATCH 11/12] Check-in new snapshot --- tests/testthat/_snaps/ggplot-legend/legend-varying-aes-guide.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/testthat/_snaps/ggplot-legend/legend-varying-aes-guide.svg diff --git a/tests/testthat/_snaps/ggplot-legend/legend-varying-aes-guide.svg b/tests/testthat/_snaps/ggplot-legend/legend-varying-aes-guide.svg new file mode 100644 index 0000000000..6654130403 --- /dev/null +++ b/tests/testthat/_snaps/ggplot-legend/legend-varying-aes-guide.svg @@ -0,0 +1 @@ +0.40.60.81.0bluegreenredxz From 80147cdbeef46517720146082ac94494a1fb94ce Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 10 Oct 2023 19:40:39 -0500 Subject: [PATCH 12/12] Update news --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index 674fb5a159..882d900d4d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # 4.10.2.9000 +## Improvements + +* `ggplotly()` now works better with the development version of ggplot2 (> v3.4.3). (#2301) + ## Bug fixes * Closed #1947: `ggplotly()` now correctly handles `geom_vline`/`geom_hline` with empty data. Previously, if `geom_vline`/`geom_hline` was passed an empty data frame, it would result in an error. The plot is drawn even if no lines are found; this is the same behavior as `ggplot2`.