Skip to content

Commit b6fb58e

Browse files
committed
safeguard against missing info
1 parent 72cb6b8 commit b6fb58e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/subplots.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ subplot <- function(..., nrows = 1, which_layout = "merge", margin = 0.02) {
7474
for (j in seq_along(xAxes[[i]])) {
7575
# before bumping axis anchor, bump trace info, where appropriate
7676
traces[[i]] <- lapply(traces[[i]], function(tr) {
77-
tr$xaxis[tr$xaxis %in% sub("axis", "", xMap[[j]])] <- sub("axis", "", names(xMap[j]))
77+
tr$xaxis[sub("axis", "", xMap[[j]]) %in% tr$xaxis] <- sub("axis", "", names(xMap[j]))
7878
tr
7979
})
8080
# bump anchors
@@ -86,7 +86,7 @@ subplot <- function(..., nrows = 1, which_layout = "merge", margin = 0.02) {
8686
}
8787
for (j in seq_along(yAxes[[i]])) {
8888
traces[[i]] <- lapply(traces[[i]], function(tr) {
89-
tr$yaxis[tr$yaxis == sub("axis", "", yMap[[j]])] <- sub("axis", "", names(yMap[j]))
89+
tr$yaxis[sub("axis", "", yMap[[j]]) %in% tr$yaxis] <- sub("axis", "", names(yMap[j]))
9090
tr
9191
})
9292
map <- xMap[xMap %in% sub("x", "xaxis", yAxes[[i]][[j]]$anchor)]
@@ -108,7 +108,7 @@ subplot <- function(..., nrows = 1, which_layout = "merge", margin = 0.02) {
108108
p$layout$shapes <- Reduce(c, shapes)
109109

110110
# merge non-axis layout stuff
111-
layouts <- lapply(layouts, function(x) x[!grepl("^[x-y]axis", names(x))])
111+
layouts <- lapply(layouts, function(x) x[!grepl("^[x-y]axis", names(x))] %||% list())
112112
if (which_layout != "merge") {
113113
if (!is.numeric(which_layout)) warning("which_layout must be numeric")
114114
if (!all(idx <- which_layout %in% seq_along(plots))) {

0 commit comments

Comments
 (0)