Reputation: 21961
I use the following to reduce width of bars in Panda:
for container in ax.containers:
plt.setp(container, width=.25)
However, on doing this, the labels on the x-axis remain at original position, as seen below. How can I move them to correspond to new bar width. In other words, is there a function to get the x coordinate of the center of each bar?
Upvotes: 0
Views: 717
Reputation: 20543
You may want to set the width during plot()
, something like this:
df.plot(kind='bar', stacked=True, width=0.25, align='center')
In the document it doesn't show you can set the width, but in fact it will take it as **kwds It will plot with the desired width with aligned x-axis labels.
Upvotes: 1