Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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

* Fixed an issue with translating `GGally::ggcorr()` via `ggplotly()`. (#2012)

# 4.10.0

Expand Down
9 changes: 6 additions & 3 deletions R/ggplotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -1390,10 +1390,13 @@ gdef2trace <- function(gdef, theme, gglayout) {
rng <- range(gdef$bar$value)
gdef$bar$value <- scales::rescale(gdef$bar$value, from = rng)
gdef$key$.value <- scales::rescale(gdef$key$.value, from = rng)
vals <- lapply(gglayout[c("xaxis", "yaxis")], function(ax) {
if (identical(ax$tickmode, "auto")) ax$ticktext else ax$tickvals
})
list(
x = with(gglayout$xaxis, if (identical(tickmode, "auto")) ticktext else tickvals)[[1]],
y = with(gglayout$yaxis, if (identical(tickmode, "auto")) ticktext else tickvals)[[1]],
# esentially to prevent this getting merged at a later point
x = vals[[1]][[1]],
y = vals[[2]][[1]],
# essentially to prevent this getting merged at a later point
name = gdef$hash,
type = "scatter",
mode = "markers",
Expand Down
19 changes: 16 additions & 3 deletions tests/testthat/test-plotly-subplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,23 @@ test_that("subplot accepts a list of plots", {
expect_true(l$layout[[sub("y", "yaxis", xaxes[[1]]$anchor)]]$domain[1] == 0)
})

test_that("ggplotly understands ggmatrix", {
test_that("ggplotly understands GGally", {
skip_if_not_installed("GGally")
L <- expect_doppelganger_built(GGally::ggpairs(iris),
"plotly-subplot-ggmatrix")
expect_doppelganger(
GGally::ggpairs(iris),
"plotly-subplot-ggmatrix"
)
d <- tibble::tibble(
v1 = 1:100 + rnorm(100, sd = 20),
v2 = 1:100 + rnorm(100, sd = 27),
v3 = rep(1, 100) + rnorm(100, sd = 1),
v4 = v1 ** 2,
v5 = v1 ** 2
)
expect_doppelganger(
ggcorr(data, method = c("everything", "pearson")),
"ggally-ggcorr"
)
})

test_that("annotation paper repositioning", {
Expand Down