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 14a0c5b

Browse filesBrowse files
authored
Merge pull request #26657 from QuLogic/fix-doc-bugs
2 parents ee0a359 + f403f2e commit 14a0c5b
Copy full SHA for 14a0c5b

File tree

8 files changed

+33
-38
lines changed
Filter options

8 files changed

+33
-38
lines changed

‎galleries/examples/text_labels_and_annotations/line_with_text.py

Copy file name to clipboardExpand all lines: galleries/examples/text_labels_and_annotations/line_with_text.py
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ def set_figure(self, figure):
2828
self.text.set_figure(figure)
2929
super().set_figure(figure)
3030

31-
def set_axes(self, axes):
32-
self.text.set_axes(axes)
33-
super().set_axes(axes)
31+
# Override the axes property setter to set Axes on our children as well.
32+
@lines.Line2D.axes.setter
33+
def axes(self, new_axes):
34+
self.text.axes = new_axes
35+
lines.Line2D.axes.fset(self, new_axes) # Call the superclass property setter.
3436

3537
def set_transform(self, transform):
3638
# 2 pixel offset

‎galleries/examples/userdemo/connectionstyle_demo.py

Copy file name to clipboardExpand all lines: galleries/examples/userdemo/connectionstyle_demo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def demo_con_style(ax, connectionstyle):
4848

4949
for ax in axs.flat:
5050
ax.set(xlim=(0, 1), ylim=(0, 1.25), xticks=[], yticks=[], aspect=1.25)
51-
fig.set_constrained_layout_pads(wspace=0, hspace=0, w_pad=0, h_pad=0)
51+
fig.get_layout_engine().set(wspace=0, hspace=0, w_pad=0, h_pad=0)
5252

5353
plt.show()
5454

‎galleries/users_explain/artists/paths.py

Copy file name to clipboardExpand all lines: galleries/users_explain/artists/paths.py
+6-9Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
could use this code:
1919
"""
2020

21+
import numpy as np
22+
2123
import matplotlib.pyplot as plt
2224

2325
import matplotlib.patches as patches
@@ -191,11 +193,6 @@
191193
# edgecolor='yellow', alpha=0.5)
192194
# ax.add_patch(patch)
193195

194-
import numpy as np
195-
196-
import matplotlib.patches as patches
197-
import matplotlib.path as path
198-
199196
fig, ax = plt.subplots()
200197
# Fixing random state for reproducibility
201198
np.random.seed(19680801)
@@ -213,9 +210,9 @@
213210

214211
nverts = nrects*(1+3+1)
215212
verts = np.zeros((nverts, 2))
216-
codes = np.ones(nverts, int) * path.Path.LINETO
217-
codes[0::5] = path.Path.MOVETO
218-
codes[4::5] = path.Path.CLOSEPOLY
213+
codes = np.full(nverts, Path.LINETO, dtype=int)
214+
codes[0::5] = Path.MOVETO
215+
codes[4::5] = Path.CLOSEPOLY
219216
verts[0::5, 0] = left
220217
verts[0::5, 1] = bottom
221218
verts[1::5, 0] = left
@@ -225,7 +222,7 @@
225222
verts[3::5, 0] = right
226223
verts[3::5, 1] = bottom
227224

228-
barpath = path.Path(verts, codes)
225+
barpath = Path(verts, codes)
229226
patch = patches.PathPatch(barpath, facecolor='green',
230227
edgecolor='yellow', alpha=0.5)
231228
ax.add_patch(patch)

‎galleries/users_explain/axes/arranging_axes.py

Copy file name to clipboardExpand all lines: galleries/users_explain/axes/arranging_axes.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def annotate_axes(ax, text, fontsize=18):
152152
fig, axd = plt.subplot_mosaic([['upper left', 'upper right'],
153153
['lower left', 'lower right']],
154154
figsize=(5.5, 3.5), layout="constrained")
155-
for k in axd:
156-
annotate_axes(axd[k], f'axd["{k}"]', fontsize=14)
155+
for k, ax in axd.items():
156+
annotate_axes(ax, f'axd[{k!r}]', fontsize=14)
157157
fig.suptitle('plt.subplot_mosaic()')
158158

159159
# %%
@@ -200,8 +200,8 @@ def annotate_axes(ax, text, fontsize=18):
200200
fig, axd = plt.subplot_mosaic([['upper left', 'right'],
201201
['lower left', 'right']],
202202
figsize=(5.5, 3.5), layout="constrained")
203-
for k in axd:
204-
annotate_axes(axd[k], f'axd["{k}"]', fontsize=14)
203+
for k, ax in axd.items():
204+
annotate_axes(ax, f'axd[{k!r}]', fontsize=14)
205205
fig.suptitle('plt.subplot_mosaic()')
206206

207207
# %%
@@ -223,8 +223,8 @@ def annotate_axes(ax, text, fontsize=18):
223223
['lower left', 'right']],
224224
gridspec_kw=gs_kw, figsize=(5.5, 3.5),
225225
layout="constrained")
226-
for k in axd:
227-
annotate_axes(axd[k], f'axd["{k}"]', fontsize=14)
226+
for k, ax in axd.items():
227+
annotate_axes(ax, f'axd[{k!r}]', fontsize=14)
228228
fig.suptitle('plt.subplot_mosaic()')
229229

230230
# %%
@@ -262,8 +262,8 @@ def annotate_axes(ax, text, fontsize=18):
262262
['lower left', 'lower right']]
263263

264264
fig, axd = plt.subplot_mosaic(outer, layout="constrained")
265-
for k in axd:
266-
annotate_axes(axd[k], f'axd["{k}"]')
265+
for k, ax in axd.items():
266+
annotate_axes(ax, f'axd[{k!r}]')
267267

268268
# %%
269269
# Low-level and advanced grid methods

‎galleries/users_explain/axes/axes_scales.py

Copy file name to clipboardExpand all lines: galleries/users_explain/axes/axes_scales.py
+7-10Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,23 @@
9898
# %%
9999
#
100100

101-
todo = ['asinh', 'symlog', 'log', 'logit', ]
102101
fig, axs = plt.subplot_mosaic([['asinh', 'symlog'],
103102
['log', 'logit']], layout='constrained')
104103

105104
x = np.arange(0, 1000)
106105

107-
for td in todo:
108-
ax = axs[td]
109-
if td in ['asinh', 'symlog']:
106+
for name, ax in axs.items():
107+
if name in ['asinh', 'symlog']:
110108
yy = x - np.mean(x)
111-
elif td in ['logit']:
109+
elif name in ['logit']:
112110
yy = (x-np.min(x))
113111
yy = yy / np.max(np.abs(yy))
114112
else:
115113
yy = x
116114

117115
ax.plot(yy, yy)
118-
ax.set_yscale(td)
119-
ax.set_title(td)
116+
ax.set_yscale(name)
117+
ax.set_title(name)
120118

121119
# %%
122120
# Optional arguments for scales
@@ -131,9 +129,8 @@
131129
fig, axs = plt.subplot_mosaic([['log', 'symlog']], layout='constrained',
132130
figsize=(6.4, 3))
133131

134-
for td in axs:
135-
ax = axs[td]
136-
if td in ['log']:
132+
for name, ax in axs.items():
133+
if name in ['log']:
137134
ax.plot(x, x)
138135
ax.set_yscale('log', base=2)
139136
ax.set_title('log base=2')

‎galleries/users_explain/figure/figure_intro.rst

Copy file name to clipboardExpand all lines: galleries/users_explain/figure/figure_intro.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ More complex grids can be achieved with `.pyplot.subplot_mosaic` (which wraps
139139

140140
fig, axs = plt.subplot_mosaic([['A', 'right'], ['B', 'right']],
141141
figsize=(4, 3), layout='constrained')
142-
for ax_name in axs:
143-
axs[ax_name].text(0.5, 0.5, ax_name, ha='center', va='center')
142+
for ax_name, ax in axs.items():
143+
ax.text(0.5, 0.5, ax_name, ha='center', va='center')
144144

145145
Sometimes we want to have a nested layout in a Figure, with two or more sets of
146146
Axes that do not share the same subplot grid.

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,17 +2466,17 @@ def __init__(self,
24662466
to avoid overlapping axes decorations. Can handle complex plot
24672467
layouts and colorbars, and is thus recommended.
24682468
2469-
See :ref:`constrainedlayout_guide`
2470-
for examples.
2469+
See :ref:`constrainedlayout_guide` for examples.
24712470
24722471
- 'compressed': uses the same algorithm as 'constrained', but
24732472
removes extra space between fixed-aspect-ratio Axes. Best for
24742473
simple grids of axes.
24752474
24762475
- 'tight': Use the tight layout mechanism. This is a relatively
24772476
simple algorithm that adjusts the subplot parameters so that
2478-
decorations do not overlap. See `.set_tight_layout` for
2479-
further details.
2477+
decorations do not overlap.
2478+
2479+
See :ref:`tight_layout_guide` for examples.
24802480
24812481
- 'none': Do not use a layout engine.
24822482

‎lib/matplotlib/legend.py

Copy file name to clipboardExpand all lines: lib/matplotlib/legend.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,6 @@ def _set_artist_props(self, a):
642642
"""
643643
a.set_figure(self.figure)
644644
if self.isaxes:
645-
# a.set_axes(self.axes)
646645
a.axes = self.axes
647646

648647
a.set_transform(self.get_transform())

0 commit comments

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