1
當我繪製水平條形圖時,當我手動設置yaxis(如下圖)時,我看到x軸和y軸都缺少一個圖例。在matplotlib中缺失標籤 - 條形圖
bar_locations = np.arange(6)
ax.barh(bar_locations, data ,alpha=.5)
bar_locations = np.arange(6)
# data = [55, 22, 40, 56, 109, 180]
# labels = ['others', u'Belts', u'Apparel & Accessories > Jewelry', u'Jewelry', u'Fragrances', u'Watches']
ax.barh(bar_locations, data ,alpha=.5)
ax.set_yticklabels(labels)
fig.tight_layout()
很酷...在x軸標籤仍下落不明。任何想法爲什麼? –
代碼中沒有** x **標籤的標籤?!你可以使用'ax.set_xlabel(「label」)來設置' – ImportanceOfBeingErnest
xaxis是根據數據自動繪製的嗎? #data = [55,22,40,56,109,180] –