How to increase the space between bar plot bars

Try replace

plt.bar(range(len(my_dict)), my_dict.values(), align='center')

with

plt.figure(figsize=(20, 3))  # width:20, height:3
plt.bar(range(len(my_dict)), my_dict.values(), align='edge', width=0.3)

The option align='edge' will eliminate white space on the left of the bar chart.

And width=0.3 sets the bars’ width smaller size than the default value.
The bars spacing will be adjusted accordingly.

For the labels along x-axis, they should be rotated 90 degrees to make them readable.

plt.xticks(range(len(my_dict)), my_dict.keys(), rotation='vertical')

Leave a Comment