繁体   English   中英

Animation 在 static plot 上 plotly

[英]Animation on top of static plot on plotly

我是 python 上的 plotly 的新手。 我试图在 static plot 之上创建一个动态 plot。 我有一个 dataframe df 如下:

Date      |    Time    | Easting   | Northing  | Truck ID
==========================================================
30/01/2019| 4:36:21 AM | 3147564   | 60394857  |  TR555
...

考虑到我现在只有 1 辆卡车。 我想为卡车的运动制作动画。 我所做的是:

import plotly.express as px
px.scatter(df, x="Easting", y="Northing", animation_frame="Time", animation_group="TruckID",
           color="TruckID",
           log_x=True, size_max=100, range_x=[min(df['Easting'])-100,max(df['Easting'])+100],
           range_y=[min(df['Northing'])-100,max(df['Northing'])+100])

这将为卡车的运动设置动画,其中散布点将根据东向和北向移动。 但是,我想以 plot static 线显示“路”

我尝试添加行:

px.line(df['Easting'], df['Northing']).show()

但它只会显示没有散点 animation 的 static 折线图。

有人可以帮忙吗?

谢谢

您所要做的就是 fig.add_trace

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM