rotating xticks causes the ticks partially hidden in matplotlib rotating xticks causes the ticks partially hidden in matplotlib python python

rotating xticks causes the ticks partially hidden in matplotlib


One good option is to rotate the tick labels.

In your specific case, you might find it convenient to use figure.autofmt_xdate() (Which will rotate the x-axis labels among other things).

Alternatively, you could do plt.setp(plt.xticks()[1], rotation=30) (or various other ways of doing the same thing).

Also, as a several year later edit, with recent versions of matplotlib, you can call fig.tight_layout() to resize things to fit the labels inside the figure, as @elgehelge notes below.


plt.tight_layout()

But be sure to add this command after plt.plot() or plt.bar()


Setting the bounding box when saving will also show the labels:

figure.savefig('myplot.png', bbox_inches='tight')