Black Lives Matter. Please consider donating to Black Girls Code today.

Several surfaces / planes for x values

Dear all,

The example below plots surfaces for z = 9 and z = 10.

library(plotly)
z <- rep(9, 4)
dim(z) <- c(2,2)
z2 <- rep(10, 4)
dim(z2) <- c(2,2)
p <- plot_ly(z=z, type="surface",showscale=FALSE)
p <- add_trace(z=z2, type="surface",showscale=FALSE)
p

I would need the same departing from x-values, i.e. planes for different values of x. The code below doesn’t work.

library(plotly)
x <- rep(9, 4)
dim(x) <- c(2,2)
x2 <- rep(10, 4)
dim(x2) <- c(2,2)
p <- plot_ly(x=x, type="surface",showscale=FALSE)
p <- add_trace(x=x2, type="surface",showscale=FALSE)
p

Any help appreciated! (I managed to do it in a complicated/slow way plotting lines and a surface between them…)

Best,

Paul