X-axis Label Gets Cut Off Of Graph

matplotlib, python

Solution

Either use:

plt.tight_layout()

or specifically set the margins, e.g. using `subplots_adjust()`:

subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)

The first solution with your example results in:

Problem

I have in my python script this ``` import matplotlib.pyplot as plt date_list = ["01/11/2015", "01/12/2015", "01/13/2015", "01/14/2015"] plt.plot([1,2,3,4], [2,4,6,8]) plt.xticks([1,2,3,4], date_list) locs, labels = plt.xticks() plt.setp(labels, rotation=45) plt.savefig('test.pdf') ``` And it produced a graph that looks like this As you can see the x label get cut off and this is not me not fully expanding the graph, I have tried that and it is still cut off. How can I get the whole label on the graph?

Original source