Skip to content

Commit 81d57e5

Browse files
committed
bug fix for passing tibbles to subplot()
1 parent 66039c8 commit 81d57e5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

R/subplots.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02
3333
shareX = FALSE, shareY = FALSE, titleX = shareX,
3434
titleY = shareY, which_layout = "merge") {
3535
dotz <- list(...)
36+
37+
if (length(dotz) == 1 && is.list(dotz[[1]]) && !is.plotly(dotz[[1]])) {
38+
# if ... is a list (or a tibble), list(...) is a (length 1) list
39+
# containing a list of plotly objects
40+
dotz <- dotz[[1]]
41+
}
42+
3643
if (tibble::is_tibble(dotz)) {
3744
# if dots is a tibble, search for one column with a list of plotly objects
3845
idx <- which(vapply(dotz, function(x) is.plotly(x[[1]]), logical(1)))
@@ -44,11 +51,8 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02
4451
)
4552
}
4653
dotz <- dotz[[idx]]
47-
} else if (length(dotz) == 1 && is.list(dotz[[1]]) && !is.plotly(dotz[[1]])) {
48-
# if ... is a list of plotly objects, list(...) is a (length 1) list
49-
# containing a list of plotly objects
50-
dotz <- dotz[[1]]
5154
}
55+
5256
# build each plot
5357
plotz <- lapply(dotz, function(d) plotly_build(d)[["x"]])
5458

0 commit comments

Comments
 (0)