类似模型那种,可以随便调整角度,保存为html 等格式。
要将Plotly生成的交互式3D图形另存为一个文件,以便之后随时查看,您可以使用Plotly的write_html
方法将图形保存为一个HTML文件。这样,您就可以在任何支持HTML的浏览器中打开和查看这个文件,而不需要重新运行代码。
import plotly.graph_objects as go
import numpy as np
# 创建网格数据
x = np.linspace(-5, 5, 50)
y = np.linspace(-5, 5, 50)
x, y = np.meshgrid(x, y)
z = np.sin(np.sqrt(x**2 + y**2))
# 创建3D曲面图
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])
# 更新布局
fig.update_layout(title='3D Surface Plot', autosize=False,
width=500, height=500,
margin=dict(l=65, r=50, b=65, t=90))
# 显示图形
fig.show()
# 将图形保存为HTML文件
fig.write_html('3D_Surface_Plot.html')