3D display with plotly

In the central figure of this year's New Year's card, the flow velocity of the ocean prediction model is displayed together with the 3D topography. 2021nenga2.gif

[plotly] Created with (https://plotly.com/python/). You can also move it around on the Jupyterlab. 8e4cfffd10104cc389c5bd302683c667.gif

The part to read the data is omitted, and the code of the part to draw the figure is as follows. Where go.Surface draws the terrain three-dimensionally, x is the x-axis, y is the y-axis, and the terrain data is in z. Ctopo is a color scale for coloring. The part where go.Cone expresses the flow velocity vector with a three-dimensional cone. (xv, yv, zv) contains 3D coordinates, and (uv, vv, wv) contains 3D vector data. In layout, the aspect ratio of the figure is changed and the coordinate axes are not displayed.

import plotly.graph_objects as go


Ctopo = [[0, 'rgb(0, 0, 70)'],[0.2, 'rgb(0,90,150)'], 
          [0.4, 'rgb(150,180,230)'], [0.5, 'rgb(210,230,250)'],
          [0.50001, 'rgb(0,120,0)'], [0.57, 'rgb(220,180,130)'], 
          [0.65, 'rgb(120,100,0)'], [0.75, 'rgb(80,70,0)'], 
          [0.9, 'rgb(200,200,200)'], [1.0, 'rgb(255,255,255)']]

fig = go.Figure(data=[go.Surface(z=z, x=x, y=y,showscale=False,colorscale=Ctopo,cmin=-3000,cmax=3000),
                      go.Cone(x=xv,y=yv,z=zv,u=uv,v=vv,w=wv,sizemode="absolute",sizeref=0.05,colorscale="turbo",opacity=0.5,cmin=0,cmax=1.5,showscale=False)])


noaxis=dict(showbackground=False,
            showgrid=False,
            showline=False,
            showticklabels=False,
            ticks='',
            title='',
            zeroline=False)


fig.update_layout( 
    width=1500, height=500,
    margin=dict(l=0, r=0, b=0, t=0),
    scene_aspectmode='manual',
    scene_aspectratio=dict(x=2, y=1, z=0.7),
    scene = dict(
        xaxis = noaxis,
        yaxis = noaxis,
        zaxis = noaxis)
    )
fig.show()

Recommended Posts

3D display with plotly
3D plot with matplotlib
3D or D with Py
Taskbar display with tqdm
Candle chart plot with plotly
Create 3d gif with python3
Create graph with plotly button
3D scatter plot with PyQtGraph
Interpolate 2D data with scipy.interpolate.griddata
Inference & result display with Tensorflow + matplotlib
Publish nice graphs online with plotly
3D skeleton structure analysis with Python
Solve ABC166 A ~ D with Python
3D drawing with SceneKit in Pythonista
Make a nice graph with plotly
How to display legend marks in one with Python 2D plot
Application of graphs with plotly sliders
[Python, Julia] 3D display in Jupyter-Mayavi library
[PyQt] Display a multi-axis graph with QtChart
Image display taken with the built-in ISIGHT
Display Disney's waiting time with LINE bot
Express Max Pooling 2D only with Conv2D
2D FEM stress analysis program with Python
Display Python 3 in the browser with MAMP
[Python] Display list elements with variadic arguments
Script example to display BoundingBox with PIL
Display Japanese graphs with VS Code + matplotlib
How to display python Japanese with lolipop
Solve AtCoder ABC168 with python (A ~ D)
Sample program to display video with PyQt
[Jupyter Notebook memo] Display kanji with matplotlib
Working with 3D data structures in pandas
2D physics simulation with Box2d and wxPython