@@ -74,7 +74,7 @@ subplot <- function(..., nrows = 1, which_layout = "merge", margin = 0.02) {
74
74
for (j in seq_along(xAxes [[i ]])) {
75
75
# before bumping axis anchor, bump trace info, where appropriate
76
76
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 ]))
78
78
tr
79
79
})
80
80
# bump anchors
@@ -86,7 +86,7 @@ subplot <- function(..., nrows = 1, which_layout = "merge", margin = 0.02) {
86
86
}
87
87
for (j in seq_along(yAxes [[i ]])) {
88
88
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 ]))
90
90
tr
91
91
})
92
92
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) {
108
108
p $ layout $ shapes <- Reduce(c , shapes )
109
109
110
110
# 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 () )
112
112
if (which_layout != " merge" ) {
113
113
if (! is.numeric(which_layout )) warning(" which_layout must be numeric" )
114
114
if (! all(idx <- which_layout %in% seq_along(plots ))) {
0 commit comments