I write a function to create barplot based on the column provide:
def bar_plot(dataset, col, figsize=(16,8)):
fig, ax = plt.subplots(figsize=figsize)
for loc in ['bottom', 'left']:
ax.spines[loc].set_visible(True)
ax.spines[loc].set_linewidth(2)
ax.spines[loc].set_color('black')
data = dataset[col].value_counts().reset_index()
ax = sns.barplot(data=data,x=col,y='index',orient='h', linewidth=1, edgecolor='k',color='#005EB8')
plt.title(f'Change counts by: {col.capitalize()}', size=16, fontweight='bold', color='#425563')
ax.set_ylabel('')
for p in ax.patches:
width = p.get_width()
plt.text(p.get_width(),
p.get_y()+.55*p.get_height(),
round(width),
va='center',
color='#425563')
When I provide the month in number, the plot is showing OK like below:
However, if I provide the full month name the last two values (Nov and Dec) are mingled in the plot:
I have been researching on it for some time now (I adjusted the yticks, ylim, etc.), but it seems without any luck so far. I can do with the month in number, but how can I fix this?