pythonmatplotlib

Increasing the space for x axis labels in Matplotlib


I'm plotting, but find that I need to increase the area underneath chart such that I can plot the labels vertically but in a font size that is not so tiny. At the moment, I have:

plt.figure(count_fig) fig, ax = plt.subplots() 
rects1 = ax.bar(ind, ratio_lst, width, color='r', linewidth=1, alpha=0.8, log=1) 
ax.set_ylabel('') 
ax.set_title('') 
ax.set_xticks(ind_width) 
ax.set_xticklabels(labels_lst, rotation='vertical', fontsize=6)

At the moment it works, but the labels often run-off the edge of the plot.


Solution

  • subplots_adjust will do it. You can play with the bottom keyword to get a good placement of the bottom of the plot.

    fig.subplots_adjust(bottom=0.2)