我必须在Python中绘制数据框中的数据。我的数据框是:
df =
time lat lon sessions
0 2014-05-06 06:28:01.525882+00:00 48.787982 11.383787 242
1 2014-05-06 06:28:22.530717+00:00 48.788082 11.383300 242
2 2014-05-06 06:29:48.550528+00:00 48.788043 11.382594 242
3 2014-05-06 06:30:05.554449+00:00 48.788040 11.381211 242
4 2014-05-06 06:30:17.557220+00:00 48.788188 11.381085 242
5 2014-05-06 06:30:27.559540+00:00 48.788753 11.381086 242
6 2014-05-06 13:17:46.022015+00:00 48.786922 11.337102 243
7 2014-05-06 13:17:57.023334+00:00 48.786888 11.338405 243
8 2014-05-06 13:18:07.024034+00:00 48.786746 11.339067 243
9 2014-05-06 13:18:18.025342+00:00 48.786281 11.341296 243
10 2014-05-06 13:18:28.026042+00:00 48.785346 11.344839 243
11 2014-05-06 13:18:38.027245+00:00 48.784328 11.348702 243
我想创建一个不同sessions
具有不同颜色的图。
答案 0 :(得分:0)
可能这个是最好的解决方案
groups = data.groupby('sessions')
fig, ax = plt.subplots()
ax.margins(0.05) # Optional, just adds 5% padding to the autoscaling
for name, group in groups:
ax.plot(group.lat, group.lon, marker='.', linestyle='', ms=12, label=name)
ax.legend()
plt.show()