import numpy as np
import plotly.graph_objects as go
np.random.seed(1)
bubble3d_data = np.random.rand(5, 100)
go.Figure(
go.Scatter3d(
x=bubble3d_data[0],
y=bubble3d_data[1],
z=bubble3d_data[2],
mode="markers", # ❶ 点で描画
# ❷ 要素のサイズと色を指定
marker={"size": bubble3d_data[3] * 10, "color": bubble3d_data[4]},
)
).show()
line3d_z = np.linspace(-2, 2, 100)
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
line3d_r = line3d_z ** 2 + 5
line3d_x = line3d_r * np.sin(theta)
line3d_y = line3d_r * np.cos(theta)
go.Figure(
go.Scatter3d(
x=line3d_x,
y=line3d_y,
z=line3d_z,
# ❶ 線で描画
mode="lines",
)
).show()
surface_x, surface_y = np.mgrid[-10:10, -10:10]
surface_z = surface_x ** 2 + surface_y ** 2 + surface_x * surface_y
go.Figure(go.Surface(x=surface_x, y=surface_y, z=surface_z)).show()
np.random.seed(1)
mesh3d_data = np.random.randn(3, 200)
go.Figure(
go.Mesh3d(x=mesh3d_data[0], y=mesh3d_data[1], z=mesh3d_data[2])
).show()