2014-03-07 545 views
2

我有這個酒吧和改變寬度值只是改變最後一個酒吧的寬度。我附上了圖片和代碼。有人知道爲什麼Matplotlib酒吧繪製寬度只改變最後一個酒吧的寬度

indexes = np.arange(len(labels)) 
width = 2 
pdb.set_trace() 
plt.bar(indexes, values, width=2, color="blueviolet") 
plt.xlabel("Phenotype identifier", fontdict=font) 

enter image description here

回答

3

因爲你的酒吧在互相圈,你的數據恰好是單調遞增的,看到的,如果你(假設indexes=range(10)):

plt.bar(indexes, range(10)[::-1], width=2, color="blueviolet") #indexes should be indices 

你會得到:

enter image description here

+0

+1,打我吧! –

+0

哦,好吧......好的,趕上!哈哈,我不希望他們這麼做。我該如何解決這個問題? – jcam77

+0

@ jcam77 - 您將左側角落位置嚴格限定爲1個單位。只要做'索引= np.arange(0,2 * len(標籤),2)'。 –