我想绘制一个使用matplotlib的条形图。我的问题是我有一些列表中的“0”值,matplotlib吃了一些这些值,我如何确保它总是绘制所有的值。Matplotlib跳过数据 -
下面是代码:
counter_trim = counter[6:(len(counter)-6)]
pos = np.arange(len(Test_names[6:]))
width =.65
ax = plt.axes()
ax.set_ylabel('Number of failures')
ax.set_title('Distribution of ABT failures')
ax.set_xticks(pos + (width/2))
xtickNames= ax.set_xticklabels(Test_names[6:])
plt.setp(xtickNames, rotation=90, fontsize=10)
plt.bar(pos, counter_trim, width, color='b')
plt.tight_layout()
print 'Distribution plot can be found here:' +image_filepath
plt.savefig(image_filepath)
为了使事情更加清楚,
这里是pos的值:[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
和counter_trim的值:[0,0,0,1,17,6,0,14,32,11,0,0,2,0,1,0,0]
的代码上面跳过前3和后2个零,但休息一切都是一样的!
任何想法如何避免这种情况?
您使用的是什么版本的matplotlib?你能清理你的示例代码,以便它可以运行(即,将你的示例数据放入snipit中,摆脱xlabel细节)?这对我来说就像一个臭虫。 – tacaswell 2013-03-22 19:36:42