Ниже приведен код, который я использую
Код: Выделить всё
import plotly.graph_objects as go
import numpy as np
mask_cylinder = False
theta = np.linspace(0, 2 * np.pi, 100)
z = np.linspace(0, 10, 100)
theta_grid, z_grid = np.meshgrid(theta, z)
r = 1
x = r * np.cos(theta_grid)
y = r * np.sin(theta_grid)
if mask_cylinder:
mask = theta_grid > np.deg2rad(25) # exclude beyond 25 degrees
x = np.where(mask, np.nan, x)
y = np.where(mask, np.nan, y)
z = np.where(mask, np.nan, z_grid)
else:
z = z_grid
fig = go.Figure()
fig.add_trace(
go.Surface(
x=x,
y=y,
z=z,
colorscale="Viridis",
showscale=True,
)
)
fig.update_layout(
title="3D Pipe",
scene=dict(
xaxis_title="X Axis",
yaxis_title="Y Axis",
zaxis_title="Z Axis",
xaxis=dict(visible=True),
yaxis=dict(visible=True),
zaxis=dict(visible=True),
),
)
fig.show()
Есть ли лучший способ исключить определенные области, сохранив при этом целостность цилиндрической геометрии?
Подробнее здесь: https://stackoverflow.com/questions/792 ... rface-plot