Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D curtain in Plotly #51

Open
ldr426 opened this issue Jul 29, 2022 · 1 comment
Open

3D curtain in Plotly #51

ldr426 opened this issue Jul 29, 2022 · 1 comment
Labels
good future ref good reference for later

Comments

@ldr426
Copy link
Collaborator

ldr426 commented Jul 29, 2022

There are two ways to create a 3D curtain in Plotly.

  • use Surface
    Every single surface comprises a ribbon. Create ribbons for every depth unit.
    image
import plotly.graph_objects as go
surface_colormap=[[1,2],[2,3],[3,4],[4,5],[5,6],[7,8]]
fig= go.Figure(data=go.Surface(
    x=[[1,1],[2,2],[3,3],[3,3],[2,2],[1,1]],
    y=[[1,1],[2,2],[3,3],[3,3],[2,2],[1,1]],
    z=[[2,1],[2,1],[2,1],[1,0],[1,0],[1,0]],
    surfacecolor=surface_colormap,
    colorscale ='Jet', 
    hovertext =surface_colormap
    ))

fig.show()
  • use Mesh3D
    use i, j, k indices to conncet three points as a triangle
    image
fig= go.Figure(data=go.Mesh3d(
    x=[1,2,3,1,2,3],
    y=[1,2,3,1,2,3],
    z=[1,1,1,2,2,2],
    intensity=[1,2,3,1,2,3],
    i=[0,1,1,4],
    j=[1,3,2,2],
    k=[3,4,4,5],
    colorscale ='Jet',
    ))

fig.show()
@ldr426
Copy link
Collaborator Author

ldr426 commented Aug 4, 2022

To just get a scatter (data point cloud):

import plotly.graph_objects as go

lon=MVBS_ds.longitude.values[:]
lat=MVBS_ds.latitude.values[:]
depth=MVBS_ds.echo_range.values[:]
plotly_data=[]

for depth in MVBS_ds_spec.echo_range.values:
    plotly_data.append(go.Scatter3d(x=lon, y=lat, z=np.full(len(lon),-depth),
                             mode='markers',
                             marker=dict(
                                 color=MVBS_ds.sel(echo_range=depth).Sv.values,
                                 colorscale='Jet',
                                 opacity=0.5)))

fig = go.Figure(data=data)
fig.show()

@ldr426 ldr426 added the good future ref good reference for later label Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good future ref good reference for later
Projects
Status: No status
Development

No branches or pull requests

1 participant