我是 matplotlib (1.3.1-2) 的新手,我找不到合适的起点。我想用 matplotlib 在直方图中绘制点随时间的分布。
基本上我想绘制日期出现的累计总和。
date
2011-12-13
2011-12-13
2013-11-01
2013-11-01
2013-06-04
2013-06-04
2014-01-01
...
那将使
2011-12-13 -> 2 times
2013-11-01 -> 3 times
2013-06-04 -> 2 times
2014-01-01 -> once
Since there will be many points over many years, I want to set the start date
on my x-Axis
and the end date
, and then mark n-time steps
(即 1 年步骤)并最终决定将有多少 bins
。
我将如何实现这一目标?
原文由 four-eyes 发布,翻译遵循 CC BY-SA 4.0 许可协议
Matplotlib 使用自己的日期/时间格式,但也提供简单的转换函数,这些函数在
dates
模块中提供。它还提供各种Locators
和Formatters
负责将刻度放置在轴上并格式化相应的标签。这应该让你开始:结果: