假设我有三个数据框,记录对象的纬度、经度和时间戳信息,每一列代表一个不同的对象,每一行代表一个时间点。
我希望绘制一个三维轨迹图,其中时间为z轴,经度为x轴,纬度为y轴,所有物体的轨迹都在同一张图上。我该如何做?
这是我的尝试,但它不起作用:
latitudes =
object 1 2 3
0 -8.064267 -8.047483 -8.056339
1 -8.064267 -8.047483 -8.056339
2 -8.064267 -8.047483 -8.056339
3 -8.064267 -8.047483 -8.056339
4 -8.064267 -8.047483 -8.056339
5 -8.064267 -8.047483 -8.056339
longitudes =
object 1 2 3
0 -34.878386 -34.904086 -34.889661
1 -34.878386 -34.904086 -34.889661
2 -34.878386 -34.904086 -34.889661
3 -34.878386 -34.904086 -34.889661
4 -34.878386 -34.904086 -34.889661
5 -34.878386 -34.904086 -34.889661
times =
object 1 2 3
0 2016-03-05 07:52:00 2016-03-05 16:26:00 2016-03-05 16:58:00
1 2016-03-05 08:19:00 2016-03-05 16:42:00 2016-03-05 17:45:00
2 2016-03-05 08:52:00 2016-03-05 17:06:00 2016-03-05 17:58:00
3 2016-03-05 09:36:00 2016-03-05 18:21:00 2016-03-05 18:23:00
4 NaT 2016-03-05 23:06:00 2016-03-05 22:38:00
5 NaT 2016-03-05 23:09:00 NaT
我希望绘制一个三维轨迹图,其中时间为z轴,经度为x轴,纬度为y轴,所有物体的轨迹都在同一张图上。我该如何做?
这是我的尝试,但它不起作用:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')
ax.plot(longitudes.values,latitudes.values,times.values)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('Time')
plt.show()
错误:
ValueError: third arg must be a format string
谢谢你