Reputation: 1368
In this bar chart:
How do I make the x-axis labels appear in the bars of the bar-chart and left-aligned with the x-axis?
I tried the ax.xaxis.labelpad()
method but it does not seem to do anything.
Upvotes: 0
Views: 81
Reputation: 69076
you can set the y
location of the ticks when you call set_xticklabels
. So, if you set y
to something small but positive, it should be placed inside the bars.
For example:
import matplotlib.pyplot as plt
fig,ax = plt.subplots(1)
ax.bar([0,1,2,3],[7900,9400,8700,9990],facecolor='#5080B0',edgecolor='k',width=0.3)
ax.set_xticks([0.15,1.15,2.15,3.15])
ax.set_xticklabels(['beek1','beek2','orbath','Kroo'],
rotation='vertical',y=0.05,va='bottom')
Produces the following plot:
Upvotes: 2