python - python plotly动画图
问题描述
我正在使用 python,我有一个时间序列数据集。我的数据包含 16 列距离作为段 0 的距离 0 和段 1 的距离 1 ...,时间。我想用图像中的时间动画绘制段(x)和距离(y)(它是一个时间戳图)
有没有办法用时间动画绘制图表,我试过 plotly.express:
Défénir le module pour le dessin des graphiques
def plot_1(数据,title_typ):
a=px.scatter(data1, x="0", y="Dist_0", animation_frame="Time",size="Ampl_0", range_x=[-1,16], range_y=[-1,40])
b=px.scatter(data1, x="1", y="Dist_1", animation_frame="Time",size="Ampl_1", range_x=[-1,16], range_y=[-1,40])
c=px.scatter(data1, x="2", y="Dist_2", animation_frame="Time",size="Ampl_2", range_x=[-1,16], range_y=[-1,40])
d=px.scatter(data1, x="3", y="Dist_3", animation_frame="Time",size="Ampl_3", range_x=[-1,16], range_y=[-1,40])
e=px.scatter(data1, x="4", y="Dist_4", animation_frame="Time",size="Ampl_4", range_x=[-1,16], range_y=[-1,40])
f=px.scatter(data1, x="5", y="Dist_5", animation_frame="Time",size="Ampl_5", range_x=[-1,16], range_y=[-1,40])
g=px.scatter(data1, x="6", y="Dist_6", animation_frame="Time",size="Ampl_6", range_x=[-1,16], range_y=[-1,40])
h=px.scatter(data1, x="7", y="Dist_7", animation_frame="Time",size="Ampl_7", range_x=[-1,16], range_y=[-1,40])
i=px.scatter(data1, x="8", y="Dist_8", animation_frame="Time",size="Ampl_8", range_x=[-1,16], range_y=[-1,40])
j=px.scatter(data1, x="9", y="Dist_9", animation_frame="Time",size="Ampl_9", range_x=[-1,16], range_y=[-1,40])
k=px.scatter(data1, x="10", y="Dist_10", animation_frame="Time",size="Ampl_10", range_x=[-1,16], range_y=[-1,40])
l=px.scatter(data1, x="11", y="Dist_11", animation_frame="Time",size="Ampl_11", range_x=[-1,16], range_y=[-1,40])
m=px.scatter(data1, x="12", y="Dist_12", animation_frame="Time",size="Ampl_12", range_x=[-1,16], range_y=[-1,40])
n=px.scatter(data1, x="13", y="Dist_13", animation_frame="Time",size="Ampl_13", range_x=[-1,16], range_y=[-1,40])
o=px.scatter(data1, x="14", y="Dist_14", animation_frame="Time",size="Ampl_14", range_x=[-1,16], range_y=[-1,40])
p=px.scatter(data1, x="15", y="Dist_15", animation_frame="Time",size="Ampl_15", range_x=[-1,16], range_y=[-1,40])
data=[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]
layout= dict(title=title_typ, xaxis=dict(title='Segment'),yaxis=dict(title='Distance (mètres)'))
fig= dict(data=data, layout=layout)
iplot(fig, filename=title_typ)
它给了我这个错误: ValueError: Invalid element(s) received for the 'size' property of scatter.marker Invalid elements include: [nan]
The 'size' property is a number and may be specified as:
- An int or float in the interval [0, inf]
- A tuple, list, or one-dimensional numpy array of the above
我尝试使用 go_scatter 但我不知道如何添加动画。
谢谢
解决方案
推荐阅读
- javascript - 上传 csv 文件并将多个标记添加到谷歌地图
- python - 根据名称 pandas python 对某些列进行乘法和求和
- swift - 更改所需属性将字段留空
- reactjs - 服务器端渲染中的 React-router 和 Link
- colors - 使用 Seaborn stripplot 中的一系列值设置色调
- rest - 在 Lagom 中查询参数
- javascript - 获取元素和所有后代/子元素的样式
- java - Spring父项目拥有bean - 孩子可以访问它吗?
- c# - 如果没有对它的引用,任务是否会被垃圾收集中断?
- javascript - Javascript在程序外保存变量