Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing labels in matplotlib - bar chart

When I draw horizontal bar chart, I see one legend missing in both x axis and y axis when I set yaxis manually like below.

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()

enter image description here

like image 327
Hari Krishnan Avatar asked Jul 19 '17 10:07

Hari Krishnan


1 Answers

You need to set the tick locations as well

ax.set_yticks(bar_locations)
ax.set_yticklabels(labels)
like image 129
ImportanceOfBeingErnest Avatar answered Sep 18 '22 18:09

ImportanceOfBeingErnest