@@ -35,9 +35,38 @@ A frequent issue raised by users of matplotlib is the lack of a layout
3535engine to nicely space out elements of the plots. While matplotlib still
3636adheres to the philosphy of giving users complete control over the placement
3737of plot elements, Jae-Joon Lee created the :mod: `~matplotlib.tight_layout `
38- module to address the most common layout issues.
38+ module and introduced a new
39+ command :func: `~matplotlib.pyplot.tight_layout `
40+ to address the most common layout issues.
3941
40- :mod: `~matplotlib.tight_layout ` will adjust the spacing between subplots
42+ .. plot ::
43+
44+ plt.rcParams['savefig.facecolor'] = "0.8"
45+ plt.rcParams['figure.figsize'] = 4, 3
46+
47+ fig, axes_list = plt.subplots(2, 1)
48+ for ax in axes_list.flat:
49+ ax.set(xlabel="x-label", ylabel="y-label", title="before tight_layout")
50+ ax.locator_params(nbins=3)
51+
52+ plt.show()
53+
54+ plt.rcParams['savefig.facecolor'] = "0.8"
55+ plt.rcParams['figure.figsize'] = 4, 3
56+
57+ fig, axes_list = plt.subplots(2, 1)
58+ for ax in axes_list.flat:
59+ ax.set(xlabel="x-label", ylabel="y-label", title="after tight_layout")
60+ ax.locator_params(nbins=3)
61+
62+ plt.tight_layout()
63+ plt.show()
64+
65+ The usage of this functionality can be as simple as ::
66+
67+ plt.tight_layout()
68+
69+ and it will adjust the spacing between subplots
4170so that the axis labels do not overlap with neighboring subplots. A
4271:ref: `plotting-guide-tight-layout ` has been created to show how to use
4372this new tool.
0 commit comments