'Plotly (R): Make a surface plane in a plotly 3d scatter plot

I have made a 3d scatter plot using plotly and on that plot I would also like to have a 3d surface plane at manual positions and geometries. I don't want to make any regression as I have seen there are similar threads. I just want to make a plane that I can move manually in the 3d plot and assign it at different positions. I have tried adding mesh3d as a "trace" with 4 points that I have tried to connect and make a plane but for some reason nothing appears. A basic scatter plot is here:

    library(plotly)

mtcars$am[which(mtcars$am == 0)] <- 'Automatic'
mtcars$am[which(mtcars$am == 1)] <- 'Manual'
mtcars$am <- as.factor(mtcars$am)

fig <- plot_ly(mtcars, x = ~wt, y = ~hp, z = ~qsec, color = ~am, colors = c('#BF382A', '#0C4B8E'))
fig <- fig %>% add_markers()
fig <- fig %>% layout(scene = list(xaxis = list(title = 'Weight'),
                     yaxis = list(title = 'Gross horsepower'),
                     zaxis = list(title = '1/4 mile time')))

fig


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source