gpt4 book ai didi

python - 以绘图方式创建 3d 曲面图

转载 作者:行者123 更新时间:2023-12-03 17:13:29 25 4
gpt4 key购买 nike

我有以下数据:
enter image description here
我正在尝试绘制 x=long, y=short, z=balance
我是这样做的:

fig.add(go.Scatter3d(x=results['long'], y=results['short'], z=results['balance']))
我得到了类似的东西:
enter image description here
我真正要找的是一个表面,就像这个例子:
enter image description here
所以,按照示例的代码,我做了:
fig.add_surface(x=results['long'], y=results['short'], z=results['balance'], row=2, col=1)
但:
enter image description here
它不仅不显示任何数据,而且似乎完全忽略了子图布局并绘制了所有内容。
这是完整的代码:
fig = make_subplots(rows=2, cols=1, specs=[[{'type': 'xy'}], [{'type': 'scene'}]])

fig.add_trace(go.Scatter(x=series1['timestamp'], y=series1['data'], line_color='red', name='series 1'), row=1, col=1)
fig.add_trace(go.Scatter(x=series2['timestamp'], y=series2['data'], line_color='blue', name='series 2'), row=1, col=1)
fig.update_yaxes(title_text="USD", row=1, col=1)

fig.add_surface(x=results['long'], y=results['short'], z=results['balance'], row=2, col=1)
fig.show()
所以,我的问题是:
  • 如何根据我拥有的数据创建平滑的表面?
  • 我错过了什么关于布局?
  • 最佳答案

    两个答案:

  • surface迹线接受 z 的二维矩阵
  • 3-d 轨迹绘制在 layout.scene 中与二维笛卡尔子图不同的对象
  • 关于python - 以绘图方式创建 3d 曲面图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57240276/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com