我想繪製一個使用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