python-3.xplotlyplotly.graph-objects

Turn off visibility of axis and grids in python plotly "go.Scatter3d"


import numpy as np
xx= np.array([[ 0,  0,  0], [ 0,  5,  0], [ 4,  5, -4], [ 4,  0,  0], [ 0,  0, -4], 
       [ 0,  5, -4],[ 4,  5,  0], [ 4,  0, -4], [ 8,  5, -4], [ 8,  0,  0], [ 8,  5,  0], 
       [ 8, 0, -4], [ 4, 10, -4], [ 4, 10,  0], [ 8, 10, -4], [ 8, 10,  0]])   
fig = go.Figure()
fig.add_trace(go.Scatter3d(x=xx[:,2],y=xx[:,0],z=xx[:,1],mode='markers'))
fig.show()

enter image description here

Just want to see the points, removing all axis and gridlines.


Solution

  • You can use scene attribute as follows:

    import numpy as np
    xx= np.array([[ 0,  0,  0], [ 0,  5,  0], [ 4,  5, -4], [ 4,  0,  0], [ 0,  0, -4], 
           [ 0,  5, -4],[ 4,  5,  0], [ 4,  0, -4], [ 8,  5, -4], [ 8,  0,  0], [ 8,  5,  0], 
           [ 8, 0, -4], [ 4, 10, -4], [ 4, 10,  0], [ 8, 10, -4], [ 8, 10,  0]])   
    
    fig = go.Figure()
    fig.add_trace(go.Scatter3d(x=xx[:,2],y=xx[:,0],z=xx[:,1],mode='markers'))
    fig.update_layout(scene = dict(xaxis = dict(showgrid = False,showticklabels = False),
                                       yaxis = dict(showgrid = False,showticklabels = False),
                                       zaxis = dict(showgrid = False,showticklabels = False)
                 ))
    fig.show()
    

    enter image description here