@@ -13,9 +13,9 @@ of ticklabels, axis labels, and titles.
13
13
Simple Example
14
14
==============
15
15
16
- In matplotlib location of axes (including subplots) are specified in
17
- normalized figure coordinate . It can happen that your axis labels or
18
- titles (or sometimes even ticklabels) go outside the figure area thus
16
+ In matplotlib, the location of axes (including subplots) are specified in
17
+ normalized figure coordinates . It can happen that your axis labels or
18
+ titles (or sometimes even ticklabels) go outside the figure area, and are thus
19
19
clipped.
20
20
21
21
.. plot ::
@@ -35,7 +35,7 @@ clipped.
35
35
fig, ax = plt.subplots()
36
36
example_plot(ax, fontsize=24)
37
37
38
- To prevent this, the location of axes need to be adjusted. For
38
+ To prevent this, the location of axes needs to be adjusted. For
39
39
subplots, this can be done by adjusting the subplot params
40
40
(:ref: `howto-subplots-adjust `). Matplotlib v1.1 introduces a new
41
41
command :func: `~matplotlib.pyplot.tight_layout ` that does this
@@ -48,7 +48,7 @@ automatically for you.
48
48
plt.tight_layout()
49
49
50
50
When you have multiple subplots, often you see labels of different
51
- axes overlaps each other.
51
+ axes overlapping each other.
52
52
53
53
.. plot ::
54
54
:include-source:
@@ -62,8 +62,8 @@ axes overlaps each other.
62
62
example_plot(ax4)
63
63
64
64
65
- * tight_layout * will also adjust spacing betweens subplots to minimize
66
- the overlaps.
65
+ :func: ` ~matplotlib.pyplot. tight_layout` will also adjust spacing between
66
+ subplots to minimize the overlaps.
67
67
68
68
.. plot ::
69
69
:include-source:
@@ -72,7 +72,7 @@ the overlaps.
72
72
plt.tight_layout()
73
73
74
74
:func: `~matplotlib.pyplot.tight_layout ` can take keyword arguments of
75
- *pad *, *w_pad * and *h_pad *. These controls the extra pad around the
75
+ *pad *, *w_pad * and *h_pad *. These control the extra padding around the
76
76
figure border and between subplots. The pads are specified in fraction
77
77
of fontsize.
78
78
@@ -83,9 +83,9 @@ of fontsize.
83
83
plt.tight_layout(pad=0.4, w_pad=0.5, h_pad=1.0)
84
84
85
85
:func: `~matplotlib.pyplot.tight_layout ` will work even if the sizes of
86
- subplot are different as far as their grid specification is
87
- compatible. In the example below, *ax1 * and *ax2 * are subplots of 2x2
88
- grid, while *ax3 * is of 1x2 grid.
86
+ subplots are different as far as their grid specification is
87
+ compatible. In the example below, *ax1 * and *ax2 * are subplots of a 2x2
88
+ grid, while *ax3 * is of a 1x2 grid.
89
89
90
90
91
91
.. plot ::
@@ -152,11 +152,13 @@ aspect != "auto" (e.g., axes with images).
152
152
Caveats
153
153
-------
154
154
155
- * *tight_layout * only considers ticklabels, axis labels, and titles. Thus, other atists may be clipped and also may overlap.
155
+ * :func: `~matplotlib.pyplot.tight_layout ` only considers ticklabels, axis
156
+ labels, and titles. Thus, other artists may be clipped and also may
157
+ overlap.
156
158
157
159
* It assumes that the extra space needed for ticklabels, axis labels,
158
160
and titles is independent of original location of axes. This is
159
- often True , but there are rare cases it is not.
161
+ often true , but there are rare cases where it is not.
160
162
161
163
* pad=0 clips some of the texts by a few pixels. This may be a bug or
162
164
a limitation of the current algorithm and it is not clear why it
@@ -169,7 +171,7 @@ Caveats
169
171
Use with GridSpec
170
172
-----------------
171
173
172
- GridSpec has its own tight_layout method
174
+ GridSpec has its own :func: ` ~matplotlib.gridspec.GridSpec. tight_layout` method
173
175
(the pyplot api :func: `~matplotlib.pyplot.tight_layout ` also works).
174
176
175
177
.. plot ::
@@ -191,9 +193,9 @@ GridSpec has its own tight_layout method
191
193
gs1.tight_layout(fig)
192
194
193
195
194
- You may provide an optional *rect * parameter, which specify the bbox
195
- that the subplots will be fit in . The coordinate must be in normalized
196
- figure coordinate and the default is (0, 0, 1, 1).
196
+ You may provide an optional *rect * parameter, which specifies the bounding box
197
+ that the subplots will be fit inside . The coordinates must be in normalized
198
+ figure coordinates and the default is (0, 0, 1, 1).
197
199
198
200
.. plot ::
199
201
:include-source:
@@ -202,7 +204,7 @@ figure coordinate and the default is (0, 0, 1, 1).
202
204
gs1.tight_layout(fig, rect=[0, 0, 0.5, 1])
203
205
204
206
205
- For example, this can be used for a figure with multiple grid_spec's .
207
+ For example, this can be used for a figure with multiple gridspecs .
206
208
207
209
.. plot ::
208
210
:include-source:
@@ -230,13 +232,13 @@ We may try to match the top and bottom of two grids ::
230
232
gs2.update(top=top, bottom=bottom)
231
233
232
234
233
- While this should be mostly good enough, but adjusting top and bottom
234
- may requires adjustment in hspace also. To update hspace & vspace, we
235
- call tight_layout again with updated rect argument. Note the rect
236
- argument specifies area including the ticklabels etc. Thus we will
237
- increase the bottom (which is 0 in normal case) by the difference
238
- between the *bottom * from above and bottom of each gridspec. Same
239
- thing for top.
235
+ While this should be mostly good enough, adjusting top and bottom
236
+ may require adjustment of hspace also. To update hspace & vspace, we
237
+ call :func: ` ~matplotlib.gridspec.GridSpec. tight_layout` again with updated
238
+ rect argument. Note that the rect argument specifies the area including the
239
+ ticklabels, etc. Thus, we will increase the bottom (which is 0 for the normal
240
+ case) by the difference between the *bottom * from above and the bottom of each
241
+ gridspec. Same thing for the top.
240
242
241
243
.. plot ::
242
244
:include-source:
@@ -256,7 +258,7 @@ thing for top.
256
258
Use with AxesGrid1
257
259
------------------
258
260
259
- While limited, axes_grid1 toolkit is also supported.
261
+ While limited, the axes_grid1 toolkit is also supported.
260
262
261
263
262
264
.. plot ::
@@ -282,8 +284,8 @@ While limited, axes_grid1 toolkit is also supported.
282
284
Colorbar
283
285
--------
284
286
285
- If you create colorbar with :func: `~matplotlib.pyplot.colorbar `
286
- command, the created colorbar is an instance of Axes not Subplot, thus
287
+ If you create a colorbar with the :func: `~matplotlib.pyplot.colorbar `
288
+ command, the created colorbar is an instance of Axes, * not * Subplot, so
287
289
tight_layout does not work. With Matplotlib v1.1, you may create a
288
290
colobar as a subplot using the gridspec.
289
291
0 commit comments