在 1 个图形上绘制多个网格
Plotting multiple meshes on 1 figure with
下面是我用来绘制 3D 网格的代码。有没有办法在一张图上绘制多个网格?对于这个例子,我希望 fig1 和 fig2 显示在同一个 graph/figure.
上
import plotly.graph_objects as go
import numpy as np
# Download data set from plotly repo
pts = np.loadtxt(np.DataSource().open('https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt'))
x, y, z = pts.T
fig1 = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z, color='lightpink', opacity=0.50)])
fig1.show()
fig2 = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z-2, color='cyan', opacity=0.50)])
fig2.show()
您可以使用 add_trace
添加到现有图形。
import plotly.graph_objects as go
import numpy as np
# Download data set from plotly repo
pts = np.loadtxt(np.DataSource().open('https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt'))
x, y, z = pts.T
fig1 = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z, color='lightpink', opacity=0.50)])
fig1.add_trace(go.Mesh3d(x=x, y=y, z=z-2, color='cyan', opacity=0.50))
fig1.show()
下面是我用来绘制 3D 网格的代码。有没有办法在一张图上绘制多个网格?对于这个例子,我希望 fig1 和 fig2 显示在同一个 graph/figure.
上import plotly.graph_objects as go
import numpy as np
# Download data set from plotly repo
pts = np.loadtxt(np.DataSource().open('https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt'))
x, y, z = pts.T
fig1 = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z, color='lightpink', opacity=0.50)])
fig1.show()
fig2 = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z-2, color='cyan', opacity=0.50)])
fig2.show()
您可以使用 add_trace
添加到现有图形。
import plotly.graph_objects as go
import numpy as np
# Download data set from plotly repo
pts = np.loadtxt(np.DataSource().open('https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt'))
x, y, z = pts.T
fig1 = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z, color='lightpink', opacity=0.50)])
fig1.add_trace(go.Mesh3d(x=x, y=y, z=z-2, color='cyan', opacity=0.50))
fig1.show()