hse*_*bie 0 python plot matplotlib pandas timeserieschart
我正在尝试绘制每次有多个点的时间序列数据。我想time在 x 轴上,Amount在 y 轴上,然后按 ID 为每个点着色,即ID = 344它们都具有相同的颜色等。
下面是我正在使用的示例数据。我确定这一定存在,但我在 Matplotlib.org 上找不到图库示例
ID Amount
Time
2015-12-09 344 0.333333
2015-12-10 345 0.333333
2015-12-09 345 0.333333
2015-12-09 344 0.750000
2015-12-09 342 0.583333
Run Code Online (Sandbox Code Playgroud)
我尝试过的事情包括尝试将数据重塑为数据透视表(不起作用,因为ID 344.Groupby有两个重复值,但我一直在努力按两列分组,我想如果我可以分组 ID 并保留时间场这将有助于解决我的问题。
任何帮助或建议将不胜感激。
阅读文档并查看 pylab 或 matplotlib 中的分散示例
import pylab as pl
fig= pl.figure( figsize=(5,5) )
ax = fig.add_subplot(111)
ax.scatter(df.index, df.Amount, s=20, c=df.ID)
Run Code Online (Sandbox Code Playgroud)
这可以定制以满足您的需求。