Search code examples
javascriptgraph3dplotlyplotly.js

Plot 2D plane in 3D graph with Plotly.js


I am using plotly.js to plot my graph and Ive come to a problem. I am trying to plot a 2D plane in 3D graph. For example i have equation x >= 5 so the plane should be perpendicular to the x axis, i can calculate the 4 corner x,y,z coordinates easily. But dont know how to plot It using either mesh3d or surface3d.


Solution

  • I would think this is a bug (just posted it here). Meanwhile, a workaround is to specify the vertex vectors:

    import plotly.graph_objects as go
    
    fig = go.Figure(go.Mesh3d(x=[0,1,1,0],
                            y=[1,1,1,1],
                            z=[0,0,1,1],
                            opacity=0.2,
                            color='black',
                            i=[0, 0, 0, 1],
                            j=[1, 2, 3, 2],
                            k=[2, 3, 1, 3],
                      ))
    fig.show()