Skip to content

Commit 7a3a465

Browse files
authored
Merge pull request #20669 from timhoffm/axs
Cleanup related to usage of axs
2 parents ca42fca + f3564cd commit 7a3a465

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

examples/color/custom_cmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
cmap_name = 'my_list'
8989
fig, axs = plt.subplots(2, 2, figsize=(6, 9))
9090
fig.subplots_adjust(left=0.02, bottom=0.06, right=0.95, top=0.94, wspace=0.05)
91-
for n_bin, ax in zip(n_bins, axs.ravel()):
91+
for n_bin, ax in zip(n_bins, axs.flat):
9292
# Create the colormap
9393
cmap = LinearSegmentedColormap.from_list(cmap_name, colors, N=n_bin)
9494
# Fewer bins will result in "coarser" colomap interpolation

examples/images_contours_and_fields/contourf_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
fig, axs = plt.subplots(2, 2, constrained_layout=True)
9898

99-
for ax, extend in zip(axs.ravel(), extends):
99+
for ax, extend in zip(axs.flat, extends):
100100
cs = ax.contourf(X, Y, Z, levels, cmap=cmap, extend=extend, origin=origin)
101101
fig.colorbar(cs, ax=ax, shrink=0.9)
102102
ax.set_title("extend = %s" % extend)

examples/style_sheets/ggplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
np.random.seed(19680801)
2424

2525
fig, axs = plt.subplots(ncols=2, nrows=2)
26-
ax1, ax2, ax3, ax4 = axs.ravel()
26+
ax1, ax2, ax3, ax4 = axs.flat
2727

2828
# scatter plot (Note: `plt.scatter` doesn't use default colors)
2929
x, y = np.random.normal(size=(2, 200))

lib/matplotlib/tests/test_axes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6439,15 +6439,15 @@ def test_secondary_formatter():
64396439
secax.xaxis.get_major_formatter(), mticker.ScalarFormatter)
64406440

64416441

6442-
def color_boxes(fig, axs):
6442+
def color_boxes(fig, ax):
64436443
"""
64446444
Helper for the tests below that test the extents of various axes elements
64456445
"""
64466446
fig.canvas.draw()
64476447

64486448
renderer = fig.canvas.get_renderer()
64496449
bbaxis = []
6450-
for nn, axx in enumerate([axs.xaxis, axs.yaxis]):
6450+
for nn, axx in enumerate([ax.xaxis, ax.yaxis]):
64516451
bb = axx.get_tightbbox(renderer)
64526452
if bb:
64536453
axisr = plt.Rectangle(
@@ -6459,23 +6459,23 @@ def color_boxes(fig, axs):
64596459

64606460
bbspines = []
64616461
for nn, a in enumerate(['bottom', 'top', 'left', 'right']):
6462-
bb = axs.spines[a].get_window_extent(renderer)
6462+
bb = ax.spines[a].get_window_extent(renderer)
64636463
spiner = plt.Rectangle(
64646464
(bb.x0, bb.y0), width=bb.width, height=bb.height,
64656465
linewidth=0.7, edgecolor="green", facecolor="none", transform=None,
64666466
zorder=3)
64676467
fig.add_artist(spiner)
64686468
bbspines += [bb]
64696469

6470-
bb = axs.get_window_extent()
6470+
bb = ax.get_window_extent()
64716471
rect2 = plt.Rectangle(
64726472
(bb.x0, bb.y0), width=bb.width, height=bb.height,
64736473
linewidth=1.5, edgecolor="magenta", facecolor="none", transform=None,
64746474
zorder=2)
64756475
fig.add_artist(rect2)
64766476
bbax = bb
64776477

6478-
bb2 = axs.get_tightbbox(renderer)
6478+
bb2 = ax.get_tightbbox(renderer)
64796479
rect2 = plt.Rectangle(
64806480
(bb2.x0, bb2.y0), width=bb2.width, height=bb2.height,
64816481
linewidth=3, edgecolor="red", facecolor="none", transform=None,

lib/matplotlib/tests/test_image.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ def test_imshow_antialiased(fig_test, fig_ref,
115115
A = np.random.rand(int(dpi * img_size), int(dpi * img_size))
116116
for fig in [fig_test, fig_ref]:
117117
fig.set_size_inches(fig_size, fig_size)
118-
axs = fig_test.subplots()
119-
axs.set_position([0, 0, 1, 1])
120-
axs.imshow(A, interpolation='antialiased')
121-
axs = fig_ref.subplots()
122-
axs.set_position([0, 0, 1, 1])
123-
axs.imshow(A, interpolation=interpolation)
118+
ax = fig_test.subplots()
119+
ax.set_position([0, 0, 1, 1])
120+
ax.imshow(A, interpolation='antialiased')
121+
ax = fig_ref.subplots()
122+
ax.set_position([0, 0, 1, 1])
123+
ax.imshow(A, interpolation=interpolation)
124124

125125

126126
@check_figures_equal(extensions=['png'])
@@ -131,14 +131,14 @@ def test_imshow_zoom(fig_test, fig_ref):
131131
A = np.random.rand(int(dpi * 3), int(dpi * 3))
132132
for fig in [fig_test, fig_ref]:
133133
fig.set_size_inches(2.9, 2.9)
134-
axs = fig_test.subplots()
135-
axs.imshow(A, interpolation='antialiased')
136-
axs.set_xlim([10, 20])
137-
axs.set_ylim([10, 20])
138-
axs = fig_ref.subplots()
139-
axs.imshow(A, interpolation='nearest')
140-
axs.set_xlim([10, 20])
141-
axs.set_ylim([10, 20])
134+
ax = fig_test.subplots()
135+
ax.imshow(A, interpolation='antialiased')
136+
ax.set_xlim([10, 20])
137+
ax.set_ylim([10, 20])
138+
ax = fig_ref.subplots()
139+
ax.imshow(A, interpolation='nearest')
140+
ax.set_xlim([10, 20])
141+
ax.set_ylim([10, 20])
142142

143143

144144
@check_figures_equal()

0 commit comments

Comments
 (0)