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 38bbf7e

Browse filesBrowse files
authored
Merge pull request matplotlib#25249 from rcomer/doc-constrained-kwarg
DOC: remove constrained_layout kwarg from tutorials and user guide
2 parents 2b05ace + 7913b62 commit 38bbf7e
Copy full SHA for 38bbf7e

File tree

Expand file treeCollapse file tree

6 files changed

+22
-22
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+22
-22
lines changed

‎doc/users/faq/howto_faq.rst

Copy file name to clipboardExpand all lines: doc/users/faq/howto_faq.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ supplied.
3030
import matplotlib.pyplot as plt
3131
import numpy as np
3232

33-
fig, ax = plt.subplots(1, 2, constrained_layout=True, figsize=(6, 2))
33+
fig, ax = plt.subplots(1, 2, layout='constrained', figsize=(6, 2))
3434

3535
ax[0].set_title('Ticks seem out of order / misplaced')
3636
x = ['5', '20', '1', '9'] # strings

‎tutorials/colors/colormap-manipulation.py

Copy file name to clipboardExpand all lines: tutorials/colors/colormap-manipulation.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def plot_examples(colormaps):
9999
data = np.random.randn(30, 30)
100100
n = len(colormaps)
101101
fig, axs = plt.subplots(1, n, figsize=(n * 2 + 2, 3),
102-
constrained_layout=True, squeeze=False)
102+
layout='constrained', squeeze=False)
103103
for [ax, cmap] in zip(axs.flat, colormaps):
104104
psm = ax.pcolormesh(data, cmap=cmap, rasterized=True, vmin=-4, vmax=4)
105105
fig.colorbar(psm, ax=ax)
@@ -197,7 +197,7 @@ def plot_examples(colormaps):
197197
def plot_linearmap(cdict):
198198
newcmp = LinearSegmentedColormap('testCmap', segmentdata=cdict, N=256)
199199
rgba = newcmp(np.linspace(0, 1, 256))
200-
fig, ax = plt.subplots(figsize=(4, 3), constrained_layout=True)
200+
fig, ax = plt.subplots(figsize=(4, 3), layout='constrained')
201201
col = ['r', 'g', 'b']
202202
for xx in [0.25, 0.5, 0.75]:
203203
ax.axvline(xx, color='0.7', linestyle='--')

‎tutorials/colors/colormapnorms.py

Copy file name to clipboardExpand all lines: tutorials/colors/colormapnorms.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
X, Y = np.mgrid[0:3:complex(0, N), 0:2:complex(0, N)]
169169
Z1 = (1 + np.sin(Y * 10.)) * X**2
170170

171-
fig, ax = plt.subplots(2, 1, constrained_layout=True)
171+
fig, ax = plt.subplots(2, 1, layout='constrained')
172172

173173
pcm = ax[0].pcolormesh(X, Y, Z1, norm=colors.PowerNorm(gamma=0.5),
174174
cmap='PuBu_r', shading='auto')
@@ -207,7 +207,7 @@
207207
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
208208
Z = ((Z1 - Z2) * 2)[:-1, :-1]
209209

210-
fig, ax = plt.subplots(2, 2, figsize=(8, 6), constrained_layout=True)
210+
fig, ax = plt.subplots(2, 2, figsize=(8, 6), layout='constrained')
211211
ax = ax.flatten()
212212

213213
# Default norm:

‎tutorials/intermediate/arranging_axes.py

Copy file name to clipboardExpand all lines: tutorials/intermediate/arranging_axes.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def annotate_axes(ax, text, fontsize=18):
329329
#
330330
# When a *GridSpec* is explicitly used, you can adjust the layout
331331
# parameters of subplots that are created from the *GridSpec*. Note this
332-
# option is not compatible with ``constrained_layout`` or
332+
# option is not compatible with *constrained layout* or
333333
# `.Figure.tight_layout` which both ignore *left* and *right* and adjust
334334
# subplot sizes to fill the figure. Usually such manual placement
335335
# requires iterations to make the Axes tick labels not overlap the Axes.
@@ -389,7 +389,7 @@ def annotate_axes(ax, text, fontsize=18):
389389
def squiggle_xy(a, b, c, d, i=np.arange(0.0, 2*np.pi, 0.05)):
390390
return np.sin(i*a)*np.cos(i*b), np.sin(i*c)*np.cos(i*d)
391391

392-
fig = plt.figure(figsize=(8, 8), constrained_layout=False)
392+
fig = plt.figure(figsize=(8, 8), layout='constrained')
393393
outer_grid = fig.add_gridspec(4, 4, wspace=0, hspace=0)
394394

395395
for a in range(4):

‎tutorials/intermediate/constrainedlayout_guide.py

Copy file name to clipboardExpand all lines: tutorials/intermediate/constrainedlayout_guide.py
+14-14Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
126126

127127
# %%
128128
# If you specify a list of Axes (or other iterable container) to the
129-
# ``ax`` argument of ``colorbar``, constrained_layout will take space from
129+
# ``ax`` argument of ``colorbar``, *constrained layout* will take space from
130130
# the specified Axes.
131131

132132
fig, axs = plt.subplots(2, 2, figsize=(4, 4), layout="constrained")
@@ -162,8 +162,8 @@ def example_plot(ax, fontsize=12, hide_labels=False):
162162
# =======
163163
#
164164
# Legends can be placed outside of their parent axis.
165-
# Constrained-layout is designed to handle this for :meth:`.Axes.legend`.
166-
# However, constrained-layout does *not* handle legends being created via
165+
# *Constrained layout* is designed to handle this for :meth:`.Axes.legend`.
166+
# However, *constrained layout* does *not* handle legends being created via
167167
# :meth:`.Figure.legend` (yet).
168168

169169
fig, ax = plt.subplots(layout="constrained")
@@ -186,7 +186,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
186186
# with ``fig.savefig('outname.png', bbox_inches='tight')``. Note,
187187
# however, that the legend's ``get_in_layout`` status will have to be
188188
# toggled again to make the saved file work, and we must manually
189-
# trigger a draw if we want constrained_layout to adjust the size
189+
# trigger a draw if we want *constrained layout* to adjust the size
190190
# of the Axes before printing.
191191

192192
fig, axs = plt.subplots(1, 2, figsize=(4, 2), layout="constrained")
@@ -195,7 +195,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
195195
axs[1].plot(np.arange(10), label='This is a plot')
196196
leg = axs[1].legend(loc='center left', bbox_to_anchor=(0.8, 0.5))
197197
leg.set_in_layout(False)
198-
# trigger a draw so that constrained_layout is executed once
198+
# trigger a draw so that constrained layout is executed once
199199
# before we turn it off when printing....
200200
fig.canvas.draw()
201201
# we want the legend included in the bbox_inches='tight' calcs.
@@ -288,7 +288,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
288288
for ax in axs.flat:
289289
example_plot(ax, hide_labels=True)
290290
# this has no effect because the space set in the gridspec trumps the
291-
# space set in constrained_layout.
291+
# space set in *constrained layout*.
292292
fig.get_layout_engine().set(w_pad=4 / 72, h_pad=4 / 72, hspace=0.0,
293293
wspace=0.0)
294294

@@ -319,7 +319,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
319319
# that can be set, either in a script or in the :file:`matplotlibrc`
320320
# file. They all have the prefix ``figure.constrained_layout``:
321321
#
322-
# - *use*: Whether to use constrained_layout. Default is False
322+
# - *use*: Whether to use *constrained layout*. Default is False
323323
# - *w_pad*, *h_pad*: Padding around Axes objects.
324324
# Float representing inches. Default is 3./72. inches (3 pts)
325325
# - *wspace*, *hspace*: Space between subplot groups.
@@ -335,7 +335,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
335335
# Use with GridSpec
336336
# =================
337337
#
338-
# constrained_layout is meant to be used
338+
# *Constrained layout* is meant to be used
339339
# with :func:`~matplotlib.figure.Figure.subplots`,
340340
# :func:`~matplotlib.figure.Figure.subplot_mosaic`, or
341341
# :func:`~matplotlib.gridspec.GridSpec` with
@@ -454,7 +454,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
454454
# ================================
455455
#
456456
# There can be good reasons to manually set an Axes position. A manual call
457-
# to `~.axes.Axes.set_position` will set the Axes so constrained_layout has
457+
# to `~.axes.Axes.set_position` will set the Axes so *constrained layout* has
458458
# no effect on it anymore. (Note that *constrained layout* still leaves the
459459
# space for the Axes that is moved).
460460

@@ -497,12 +497,12 @@ def example_plot(ax, fontsize=12, hide_labels=False):
497497
#
498498
# *Constrained layout* usually adjusts the Axes positions on each draw
499499
# of the figure. If you want to get the spacing provided by
500-
# *Constrained layout* but not have it update, then do the initial
500+
# *constrained layout* but not have it update, then do the initial
501501
# draw and then call ``fig.set_layout_engine('none')``.
502502
# This is potentially useful for animations where the tick labels may
503503
# change length.
504504
#
505-
# Note that *Constrained layout* is turned off for ``ZOOM`` and ``PAN``
505+
# Note that *constrained layout* is turned off for ``ZOOM`` and ``PAN``
506506
# GUI events for the backends that use the toolbar. This prevents the
507507
# Axes from changing position during zooming and panning.
508508
#
@@ -517,7 +517,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
517517
# number of rows and columns is the same for each call.
518518
# The reason is that each call to `.pyplot.subplot` will create a new
519519
# `.GridSpec` instance if the geometry is not the same, and
520-
# *Constrained layout*. So the following works fine:
520+
# *constrained layout*. So the following works fine:
521521

522522
fig = plt.figure(layout="constrained")
523523

@@ -588,7 +588,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
588588
# Debugging
589589
# =========
590590
#
591-
# Constrained-layout can fail in somewhat unexpected ways. Because it uses
591+
# *Constrained layout* can fail in somewhat unexpected ways. Because it uses
592592
# a constraint solver the solver can find solutions that are mathematically
593593
# correct, but that aren't at all what the user wants. The usual failure
594594
# mode is for all sizes to collapse to their smallest allowable value. If
@@ -615,7 +615,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
615615
# into rows and columns, with the relative width of the Axes in those
616616
# rows and columns set by *width_ratios* and *height_ratios*.
617617
#
618-
# In constrained_layout, each gridspec gets a *layoutgrid* associated with
618+
# In *constrained layout*, each gridspec gets a *layoutgrid* associated with
619619
# it. The *layoutgrid* has a series of ``left`` and ``right`` variables
620620
# for each column, and ``bottom`` and ``top`` variables for each row, and
621621
# further it has a margin for each of left, right, bottom and top. In each

‎tutorials/intermediate/legend_guide.py

Copy file name to clipboardExpand all lines: tutorials/intermediate/legend_guide.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
# --------------
142142
#
143143
# Sometimes it makes more sense to place a legend relative to the (sub)figure
144-
# rather than individual Axes. By using ``constrained_layout`` and
144+
# rather than individual Axes. By using *constrained layout* and
145145
# specifying "outside" at the beginning of the *loc* keyword argument,
146146
# the legend is drawn outside the Axes on the (sub)figure.
147147

0 commit comments

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