0
我有一个数组,其时间戳为ts_array
,格式为dd-mm-yyyy
,如03-08-2012
。现在我想用matplotlib 1.5.1
绘制直方图和Python 2.7
如下:使用Python生成直方图
import matplotlib.pyplot as plt
timestamps = dict((x, ts_array.count(x)) for x in ts_array)
plt.hist(timestamps)
plt.title("Timestamp Histogram")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()
例如在哪里timestamps = {'03-08-2012': 108, '15-08-2012': 16}
。
当我尝试运行它时,它会抛出TypeError: len() of unsized object
。我如何绘制一个直方图,其中x轴上的日期(键)和y轴上的计数(值)?