Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e0dcac8

Browse filesBrowse files
committed
DOC: remove constrained_layout kwarg from examples [ci doc]
1 parent 75e2d22 commit e0dcac8
Copy full SHA for e0dcac8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

41 files changed

+95
-98
lines changed

‎examples/axisartist/simple_axisartist1.py

Copy file name to clipboardExpand all lines: examples/axisartist/simple_axisartist1.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from mpl_toolkits import axisartist
2020

21-
fig = plt.figure(figsize=(6, 3), constrained_layout=True)
21+
fig = plt.figure(figsize=(6, 3), layout="constrained")
2222
# To construct axes of two different classes, we need to use gridspec (or
2323
# MATLAB-style add_subplot calls).
2424
gs = fig.add_gridspec(1, 2)

‎examples/images_contours_and_fields/contourf_demo.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/contourf_demo.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# a good idea, because they don't occur on nice boundaries, but we do it here
4141
# for purposes of illustration.
4242

43-
fig1, ax2 = plt.subplots(constrained_layout=True)
43+
fig1, ax2 = plt.subplots(layout='constrained')
4444
CS = ax2.contourf(X, Y, Z, 10, cmap=plt.cm.bone, origin=origin)
4545

4646
# Note that in the following, we explicitly pass in a subset of the contour
@@ -66,7 +66,7 @@
6666
# Now make a contour plot with the levels specified, and with the colormap
6767
# generated automatically from a list of colors.
6868

69-
fig2, ax2 = plt.subplots(constrained_layout=True)
69+
fig2, ax2 = plt.subplots(layout='constrained')
7070
levels = [-1.5, -1, -0.5, 0, 0.5, 1]
7171
CS3 = ax2.contourf(X, Y, Z, levels,
7272
colors=('r', 'g', 'b'),
@@ -101,7 +101,7 @@
101101
# no effect:
102102
# cmap.set_bad("red")
103103

104-
fig, axs = plt.subplots(2, 2, constrained_layout=True)
104+
fig, axs = plt.subplots(2, 2, layout="constrained")
105105

106106
for ax, extend in zip(axs.flat, extends):
107107
cs = ax.contourf(X, Y, Z, levels, cmap=cmap, extend=extend, origin=origin)

‎examples/images_contours_and_fields/image_antialiasing.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/image_antialiasing.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
# original colormap, so it is no longer possible to invert individual
6767
# pixels back to their data value.
6868

69-
fig, axs = plt.subplots(2, 2, figsize=(5, 6), constrained_layout=True)
69+
fig, axs = plt.subplots(2, 2, figsize=(5, 6), layout='constrained')
7070
axs[0, 0].imshow(a, interpolation='nearest', cmap='RdBu_r')
7171
axs[0, 0].set_xlim(100, 200)
7272
axs[0, 0].set_ylim(275, 175)
@@ -104,7 +104,7 @@
104104
# Apart from the default 'hanning' antialiasing, `~.Axes.imshow` supports a
105105
# number of different interpolation algorithms, which may work better or
106106
# worse depending on the pattern.
107-
fig, axs = plt.subplots(1, 2, figsize=(7, 4), constrained_layout=True)
107+
fig, axs = plt.subplots(1, 2, figsize=(7, 4), layout='constrained')
108108
for ax, interp in zip(axs, ['hanning', 'lanczos']):
109109
ax.imshow(a, interpolation=interp, cmap='gray')
110110
ax.set_title(f"interpolation='{interp}'")

‎examples/images_contours_and_fields/image_nonuniform.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/image_nonuniform.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
z = np.sqrt(x[np.newaxis, :]**2 + y[:, np.newaxis]**2)
2828

29-
fig, axs = plt.subplots(nrows=2, ncols=2, constrained_layout=True)
29+
fig, axs = plt.subplots(nrows=2, ncols=2, layout='constrained')
3030
fig.suptitle('NonUniformImage class', fontsize='large')
3131
ax = axs[0, 0]
3232
im = NonUniformImage(ax, interpolation=interp, extent=(-4, 4, -4, 4),

‎examples/images_contours_and_fields/pcolormesh_grids.py

Copy file name to clipboardExpand all lines: examples/images_contours_and_fields/pcolormesh_grids.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _annotate(ax, x, y, title):
8989
# to use, in this case ``shading='auto'`` will decide whether to use 'flat' or
9090
# 'nearest' shading based on the shapes of *X*, *Y* and *Z*.
9191

92-
fig, axs = plt.subplots(2, 1, constrained_layout=True)
92+
fig, axs = plt.subplots(2, 1, layout='constrained')
9393
ax = axs[0]
9494
x = np.arange(ncols)
9595
y = np.arange(nrows)
@@ -110,7 +110,7 @@ def _annotate(ax, x, y, title):
110110
# be specified, where the color in the quadrilaterals is linearly interpolated
111111
# between the grid points. The shapes of *X*, *Y*, *Z* must be the same.
112112

113-
fig, ax = plt.subplots(constrained_layout=True)
113+
fig, ax = plt.subplots(layout='constrained')
114114
x = np.arange(ncols)
115115
y = np.arange(nrows)
116116
ax.pcolormesh(x, y, Z, shading='gouraud', vmin=Z.min(), vmax=Z.max())

‎examples/lines_bars_and_markers/barchart.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/barchart.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
width = 0.25 # the width of the bars
2424
multiplier = 0
2525

26-
fig, ax = plt.subplots(constrained_layout=True)
26+
fig, ax = plt.subplots(layout='constrained')
2727

2828
for attribute, measurement in penguin_means.items():
2929
offset = width * multiplier

‎examples/lines_bars_and_markers/curve_error_band.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/curve_error_band.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def draw_error_band(ax, x, y, err, **kwargs):
6363
ax.add_patch(PathPatch(path, **kwargs))
6464

6565

66-
axs = (plt.figure(constrained_layout=True)
67-
.subplots(1, 2, sharex=True, sharey=True))
66+
_, axs = plt.subplots(1, 2, layout='constrained', sharex=True, sharey=True)
6867
errs = [
6968
(axs[0], "constant error", 0.05),
7069
(axs[1], "variable error", 0.05 * np.sin(2 * t) ** 2 + 0.04),

‎examples/lines_bars_and_markers/markevery_demo.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/markevery_demo.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# markevery with linear scales
4545
# ----------------------------
4646

47-
fig, axs = plt.subplots(3, 3, figsize=(10, 6), constrained_layout=True)
47+
fig, axs = plt.subplots(3, 3, figsize=(10, 6), layout='constrained')
4848
for ax, markevery in zip(axs.flat, cases):
4949
ax.set_title(f'markevery={markevery}')
5050
ax.plot(x, y, 'o', ls='-', ms=4, markevery=markevery)
@@ -58,7 +58,7 @@
5858
# fraction of figure size creates even distributions, because it's based on
5959
# fractions of the Axes diagonal, not on data coordinates or data indices.
6060

61-
fig, axs = plt.subplots(3, 3, figsize=(10, 6), constrained_layout=True)
61+
fig, axs = plt.subplots(3, 3, figsize=(10, 6), layout='constrained')
6262
for ax, markevery in zip(axs.flat, cases):
6363
ax.set_title(f'markevery={markevery}')
6464
ax.set_xscale('log')
@@ -75,7 +75,7 @@
7575
# diagonal, it changes the displayed data range, and more points will be
7676
# displayed when zooming.
7777

78-
fig, axs = plt.subplots(3, 3, figsize=(10, 6), constrained_layout=True)
78+
fig, axs = plt.subplots(3, 3, figsize=(10, 6), layout='constrained')
7979
for ax, markevery in zip(axs.flat, cases):
8080
ax.set_title(f'markevery={markevery}')
8181
ax.plot(x, y, 'o', ls='-', ms=4, markevery=markevery)
@@ -89,7 +89,7 @@
8989
r = np.linspace(0, 3.0, 200)
9090
theta = 2 * np.pi * r
9191

92-
fig, axs = plt.subplots(3, 3, figsize=(10, 6), constrained_layout=True,
92+
fig, axs = plt.subplots(3, 3, figsize=(10, 6), layout='constrained',
9393
subplot_kw={'projection': 'polar'})
9494
for ax, markevery in zip(axs.flat, cases):
9595
ax.set_title(f'markevery={markevery}')

‎examples/lines_bars_and_markers/psd_demo.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/psd_demo.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
xn = (A * np.sin(2 * np.pi * f * t)).sum(axis=0)
113113
xn += 5 * np.random.randn(*t.shape)
114114

115-
fig, (ax0, ax1) = plt.subplots(ncols=2, constrained_layout=True)
115+
fig, (ax0, ax1) = plt.subplots(ncols=2, layout='constrained')
116116

117117
yticks = np.arange(-50, 30, 10)
118118
yrange = (yticks[0], yticks[-1])
@@ -152,7 +152,7 @@
152152
f = np.array([150, 140]).reshape(-1, 1)
153153
xn = (A * np.exp(2j * np.pi * f * t)).sum(axis=0) + 5 * prng.randn(*t.shape)
154154

155-
fig, (ax0, ax1) = plt.subplots(ncols=2, constrained_layout=True)
155+
fig, (ax0, ax1) = plt.subplots(ncols=2, layout='constrained')
156156

157157
yticks = np.arange(-50, 30, 10)
158158
yrange = (yticks[0], yticks[-1])

‎examples/lines_bars_and_markers/scatter_hist.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/scatter_hist.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def scatter_hist(x, y, ax, ax_histx, ax_histy):
8989
# of the axes.
9090

9191
# Create a Figure, which doesn't have to be square.
92-
fig = plt.figure(constrained_layout=True)
92+
fig = plt.figure(layout='constrained')
9393
# Create the main axes, leaving 25% of the figure space at the top and on the
9494
# right to position marginals.
9595
ax = fig.add_gridspec(top=0.75, right=0.75).subplots()

‎examples/lines_bars_and_markers/timeline.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/timeline.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
int(np.ceil(len(dates)/6)))[:len(dates)]
7171

7272
# Create figure and plot a stem plot with the date
73-
fig, ax = plt.subplots(figsize=(8.8, 4), constrained_layout=True)
73+
fig, ax = plt.subplots(figsize=(8.8, 4), layout="constrained")
7474
ax.set(title="Matplotlib release dates")
7575

7676
ax.vlines(dates, 0, levels, color="tab:red") # The vertical stems.

‎examples/misc/rasterization_demo.py

Copy file name to clipboardExpand all lines: examples/misc/rasterization_demo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
xx = x*np.cos(theta) - y*np.sin(theta) # rotate x by -theta
4545
yy = x*np.sin(theta) + y*np.cos(theta) # rotate y by -theta
4646

47-
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, constrained_layout=True)
47+
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, layout="constrained")
4848

4949
# pcolormesh without rasterization
5050
ax1.set_aspect(1)

‎examples/scales/asinh_demo.py

Copy file name to clipboardExpand all lines: examples/scales/asinh_demo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
# %%
6767
# Compare "asinh" graphs with different scale parameter "linear_width":
68-
fig2 = plt.figure(constrained_layout=True)
68+
fig2 = plt.figure(layout='constrained')
6969
axs = fig2.subplots(1, 3, sharex=True)
7070
for ax, (a0, base) in zip(axs, ((0.2, 2), (1.0, 0), (5.0, 10))):
7171
ax.set_title(f'linear_width={a0:.3g}')

‎examples/scales/scales.py

Copy file name to clipboardExpand all lines: examples/scales/scales.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
x = np.arange(len(y))
2525

2626
# plot with various axes scales
27-
fig, axs = plt.subplots(3, 2, figsize=(6, 8),
28-
constrained_layout=True)
27+
fig, axs = plt.subplots(3, 2, figsize=(6, 8), layout='constrained')
2928

3029
# linear
3130
ax = axs[0, 0]

‎examples/shapes_and_collections/hatch_style_reference.py

Copy file name to clipboardExpand all lines: examples/shapes_and_collections/hatch_style_reference.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from matplotlib.patches import Rectangle
1919

20-
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2))
20+
fig, axs = plt.subplots(2, 5, layout='constrained', figsize=(6.4, 3.2))
2121

2222
hatches = ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']
2323

@@ -34,7 +34,7 @@ def hatches_plot(ax, h):
3434
# %%
3535
# Hatching patterns can be repeated to increase the density.
3636

37-
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2))
37+
fig, axs = plt.subplots(2, 5, layout='constrained', figsize=(6.4, 3.2))
3838

3939
hatches = ['//', '\\\\', '||', '--', '++', 'xx', 'oo', 'OO', '..', '**']
4040

@@ -44,7 +44,7 @@ def hatches_plot(ax, h):
4444
# %%
4545
# Hatching patterns can be combined to create additional patterns.
4646

47-
fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2))
47+
fig, axs = plt.subplots(2, 5, layout='constrained', figsize=(6.4, 3.2))
4848

4949
hatches = ['/o', '\\|', '|*', '-\\', '+o', 'x*', 'o-', 'O|', 'O.', '*-']
5050

‎examples/spines/spines.py

Copy file name to clipboardExpand all lines: examples/spines/spines.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
y = 2 * np.sin(x)
2323

2424
# Constrained layout makes sure the labels don't overlap the axes.
25-
fig, (ax0, ax1, ax2) = plt.subplots(nrows=3, constrained_layout=True)
25+
fig, (ax0, ax1, ax2) = plt.subplots(nrows=3, layout='constrained')
2626

2727
ax0.plot(x, y)
2828
ax0.set_title('normal spines')

‎examples/statistics/barchart_demo.py

Copy file name to clipboardExpand all lines: examples/statistics/barchart_demo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def format_score(score):
4545

4646

4747
def plot_student_results(student, scores_by_test, cohort_size):
48-
fig, ax1 = plt.subplots(figsize=(9, 7), constrained_layout=True)
48+
fig, ax1 = plt.subplots(figsize=(9, 7), layout='constrained')
4949
fig.canvas.manager.set_window_title('Eldorado K-8 Fitness Chart')
5050

5151
ax1.set_title(student.name)

‎examples/statistics/time_series_histogram.py

Copy file name to clipboardExpand all lines: examples/statistics/time_series_histogram.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
from matplotlib.colors import LogNorm
3434

35-
fig, axes = plt.subplots(nrows=3, figsize=(6, 8), constrained_layout=True)
35+
fig, axes = plt.subplots(nrows=3, figsize=(6, 8), layout='constrained')
3636

3737
# Make some data; a 1D random walk + small fraction of sine waves
3838
num_series = 1000

‎examples/style_sheets/style_sheets_reference.py

Copy file name to clipboardExpand all lines: examples/style_sheets/style_sheets_reference.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def plot_figure(style_label=""):
117117
prng = np.random.RandomState(96917002)
118118

119119
fig, axs = plt.subplots(ncols=6, nrows=1, num=style_label,
120-
figsize=(14.8, 2.8), constrained_layout=True)
120+
figsize=(14.8, 2.8), layout='constrained')
121121

122122
# make a suptitle, in the same style for all subfigures,
123123
# except those with dark backgrounds, which get a lighter color:

‎examples/subplots_axes_and_figures/axes_box_aspect.py

Copy file name to clipboardExpand all lines: examples/subplots_axes_and_figures/axes_box_aspect.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
# height. `~.Axes.set_box_aspect` provides an easy solution to that by allowing
7575
# to have the normal plot's axes use the images dimensions as box aspect.
7676
#
77-
# This example also shows that ``constrained_layout`` interplays nicely with
77+
# This example also shows that *constrained layout* interplays nicely with
7878
# a fixed box aspect.
7979

80-
fig4, (ax, ax2) = plt.subplots(ncols=2, constrained_layout=True)
80+
fig4, (ax, ax2) = plt.subplots(ncols=2, layout="constrained")
8181

8282
np.random.seed(19680801) # Fixing random state for reproducibility
8383
im = np.random.rand(16, 27)
@@ -139,7 +139,7 @@
139139
# following creates a 2 by 3 subplot grid with all square Axes.
140140

141141
fig7, axs = plt.subplots(2, 3, subplot_kw=dict(box_aspect=1),
142-
sharex=True, sharey=True, constrained_layout=True)
142+
sharex=True, sharey=True, layout="constrained")
143143

144144
for i, ax in enumerate(axs.flat):
145145
ax.scatter(i % 3, -((i // 3) - 0.5)*200, c=[plt.cm.hsv(i / 6)], s=300)

‎examples/subplots_axes_and_figures/colorbar_placement.py

Copy file name to clipboardExpand all lines: examples/subplots_axes_and_figures/colorbar_placement.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
# %%
4343
# Relatively complicated colorbar layouts are possible using this
4444
# paradigm. Note that this example works far better with
45-
# ``constrained_layout=True``
45+
# ``layout='constrained'``
4646

47-
fig, axs = plt.subplots(3, 3, constrained_layout=True)
47+
fig, axs = plt.subplots(3, 3, layout='constrained')
4848
for ax in axs.flat:
4949
pcm = ax.pcolormesh(np.random.random((20, 20)))
5050

@@ -60,7 +60,7 @@
6060
# Placing colorbars for axes with a fixed aspect ratio pose a particular
6161
# challenge as the parent axes changes size depending on the data view.
6262

63-
fig, axs = plt.subplots(2, 2, constrained_layout=True)
63+
fig, axs = plt.subplots(2, 2, layout='constrained')
6464
cmaps = ['RdBu_r', 'viridis']
6565
for col in range(2):
6666
for row in range(2):
@@ -79,7 +79,7 @@
7979
# axes in axes coordinates. Note that if you zoom in on the axes, and
8080
# change the shape of the axes, the colorbar will also change position.
8181

82-
fig, axs = plt.subplots(2, 2, constrained_layout=True)
82+
fig, axs = plt.subplots(2, 2, layout='constrained')
8383
cmaps = ['RdBu_r', 'viridis']
8484
for col in range(2):
8585
for row in range(2):

‎examples/subplots_axes_and_figures/demo_constrained_layout.py

Copy file name to clipboardExpand all lines: examples/subplots_axes_and_figures/demo_constrained_layout.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Resizing axes with constrained layout
44
=====================================
55
6-
Constrained layout attempts to resize subplots in
6+
*Constrained layout* attempts to resize subplots in
77
a figure so that there are no overlaps between axes objects and labels
88
on the axes.
99
@@ -23,25 +23,25 @@ def example_plot(ax):
2323

2424

2525
# %%
26-
# If we don't use constrained_layout, then labels overlap the axes
26+
# If we don't use *constrained layout*, then labels overlap the axes
2727

28-
fig, axs = plt.subplots(nrows=2, ncols=2, constrained_layout=False)
28+
fig, axs = plt.subplots(nrows=2, ncols=2, layout=None)
2929

3030
for ax in axs.flat:
3131
example_plot(ax)
3232

3333
# %%
34-
# adding ``constrained_layout=True`` automatically adjusts.
34+
# adding ``layout='constrained'`` automatically adjusts.
3535

36-
fig, axs = plt.subplots(nrows=2, ncols=2, constrained_layout=True)
36+
fig, axs = plt.subplots(nrows=2, ncols=2, layout='constrained')
3737

3838
for ax in axs.flat:
3939
example_plot(ax)
4040

4141
# %%
4242
# Below is a more complicated example using nested gridspecs.
4343

44-
fig = plt.figure(constrained_layout=True)
44+
fig = plt.figure(layout='constrained')
4545

4646
import matplotlib.gridspec as gridspec
4747

‎examples/subplots_axes_and_figures/figure_title.py

Copy file name to clipboardExpand all lines: examples/subplots_axes_and_figures/figure_title.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
x = np.linspace(0.0, 5.0, 501)
1919

20-
fig, (ax1, ax2) = plt.subplots(1, 2, constrained_layout=True, sharey=True)
20+
fig, (ax1, ax2) = plt.subplots(1, 2, layout='constrained', sharey=True)
2121
ax1.plot(x, np.cos(6*x) * np.exp(-x))
2222
ax1.set_title('damped')
2323
ax1.set_xlabel('time (s)')
@@ -33,7 +33,7 @@
3333
# A global x- or y-label can be set using the `.FigureBase.supxlabel` and
3434
# `.FigureBase.supylabel` methods.
3535

36-
fig, axs = plt.subplots(3, 5, figsize=(8, 5), constrained_layout=True,
36+
fig, axs = plt.subplots(3, 5, figsize=(8, 5), layout='constrained',
3737
sharex=True, sharey=True)
3838

3939
fname = get_sample_data('percent_bachelors_degrees_women_usa.csv',

‎examples/subplots_axes_and_figures/gridspec_multicolumn.py

Copy file name to clipboardExpand all lines: examples/subplots_axes_and_figures/gridspec_multicolumn.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def format_axes(fig):
1818
ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
1919
ax.tick_params(labelbottom=False, labelleft=False)
2020

21-
fig = plt.figure(constrained_layout=True)
21+
fig = plt.figure(layout="constrained")
2222

2323
gs = GridSpec(3, 3, figure=fig)
2424
ax1 = fig.add_subplot(gs[0, :])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.