【发布时间】:2021-07-21 09:27:52
【问题描述】:
我想在 python 中使用 plotly 制作 3D 绘图。实际上它是动画的第一步,但首先我需要知道如何创建它的 3D 散点图,如下所示,它是在 matplotlib 中制作的。 我有dataset,看起来像这样。
现在,我想根据提到的日期对其进行动画处理,但是我在 plotly 的官方网站上获得的代码是这样的,其中大多数是相似的。
import plotly.express as px
df = px.data.iris()
fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',
color='species')
fig.show()
现在,我不明白应该如何分配 X,Y and Z 来获得动画情节。因为我需要的所有 13 列都在针对日期的情节中。
作为参考,我发现了这个site 也就是说,
To get a 3D scatter plot you need to specify the trace as a plotly.graph_objs.Scatter3d object or as a dict with a type: 'scatter3d' key.
Feel free to share a full reproducible example if you’d like to work through more of the details.
但这还不够。
请帮我解决这个问题。正确代码或指导的链接对于如何设置变量以获得 3D 绘图动画非常有帮助。谢谢。
【问题讨论】:
标签: python matplotlib plotly