Skip to content

Commit e0dcac8

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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+95
-98
lines changed

examples/axisartist/simple_axisartist1.py

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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()

0 commit comments

Comments
 (0)