Search code examples
pythonplotlyalpha-shape

Problem to diplay a 3d mesh using alphahull >0 with plotly in jupyter notebook


I tried the following example 3D Mesh example with AlphaNull to test alphahull but my jupyter notebook display just something blank.

When I set alphahull=5, the display is blank: result for alphahull=5

But when i set alphahull = 0, it works: result for alphahull = 0

and when i set alphahull = -1, it works : result for alphahull = -1

Why is this happening and how can I fix it? Thank you in advance for your help.


Solution

  • Unfortunately I think rendering for alphahull values larger than 0 may be broken as of the latest plotly update. I noticed that in the documentation page, their code example with alphahull=5 also doesn't render. I tried with other positive values and none of these render either (the same alpha shape algorithm is used for any alphanull > 0)

    However, I tried downgrading to plotly==4.14.0 and the same example with alphahull=5 does render.

    import plotly.graph_objects as go
    import numpy as np
    
    pts = np.loadtxt(np.DataSource().open('https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt'))
    x, y, z = pts.T
    
    fig = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z,
                       alphahull=5,
                       opacity=0.4,
                       color='cyan')])
    fig.show()
    

    enter image description here

    So in your jupyter notebook, you can run the line !pip install plotly==4.14.0 in a separate cell and see if that allows you to render positive alphahull values.