Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increasing the space for x axis labels in Matplotlib

Tags:

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.

like image 922
disruptive Avatar asked May 28 '15 14:05

disruptive


People also ask

How do you increase X-axis spacing?

To adjust the spacing between the edge of the plot and the X-axis, we can use tight_layout() method or set the bottom padding of the current figure. Set the figure size and adjust the padding between and around the subplots.

How do I increase the size of axis labels in MatPlotLib?

If we want to change the font size of the axis labels, we can use the parameter “fontsize” and set it your desired number.

How do I increase space between bars in MatPlotLib?

The space between bars can be added by using rwidth parameter inside the “plt. hist()” function. This value specifies the width of the bar with respect to its default width and the value of rwidth cannot be greater than 1.


1 Answers

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) 
like image 54
tmdavison Avatar answered Oct 16 '22 15:10

tmdavison