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 791ad1b

Browse filesBrowse files
committed
Consistently use axs to refer to a set of Axes
1 parent a4d82fe commit 791ad1b
Copy full SHA for 791ad1b
Expand file treeCollapse file tree

27 files changed

+288
-280
lines changed

‎examples/color/colormap_reference.py

Copy file name to clipboardExpand all lines: examples/color/colormap_reference.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ def plot_color_gradients(cmap_category, cmap_list):
4848
# Create figure and adjust figure height to number of colormaps
4949
nrows = len(cmap_list)
5050
figh = 0.35 + 0.15 + (nrows + (nrows-1)*0.1)*0.22
51-
fig, axes = plt.subplots(nrows=nrows, figsize=(6.4, figh))
51+
fig, axs = plt.subplots(nrows=nrows, figsize=(6.4, figh))
5252
fig.subplots_adjust(top=1-.35/figh, bottom=.15/figh, left=0.2, right=0.99)
5353

54-
axes[0].set_title(cmap_category + ' colormaps', fontsize=14)
54+
axs[0].set_title(cmap_category + ' colormaps', fontsize=14)
5555

56-
for ax, name in zip(axes, cmap_list):
56+
for ax, name in zip(axs, cmap_list):
5757
ax.imshow(gradient, aspect='auto', cmap=plt.get_cmap(name))
5858
ax.text(-.01, .5, name, va='center', ha='right', fontsize=10,
5959
transform=ax.transAxes)
6060

6161
# Turn off *all* ticks & spines, not just the ones with colormaps.
62-
for ax in axes:
62+
for ax in axs:
6363
ax.set_axis_off()
6464

6565

‎examples/lines_bars_and_markers/marker_reference.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/marker_reference.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ def split_list(a_list):
3939
#
4040
# Plot all un-filled markers
4141

42-
fig, axes = plt.subplots(ncols=2)
42+
fig, axs = plt.subplots(ncols=2)
4343
fig.suptitle('un-filled markers', fontsize=14)
4444

4545
# Filter out filled markers and marker settings that do nothing.
4646
unfilled_markers = [m for m, func in Line2D.markers.items()
4747
if func != 'nothing' and m not in Line2D.filled_markers]
4848

49-
for ax, markers in zip(axes, split_list(unfilled_markers)):
49+
for ax, markers in zip(axs, split_list(unfilled_markers)):
5050
for y, marker in enumerate(markers):
5151
ax.text(-0.5, y, repr(marker), **text_style)
5252
ax.plot(y * points, marker=marker, **marker_style)
@@ -58,8 +58,8 @@ def split_list(a_list):
5858
###############################################################################
5959
# Plot all filled markers.
6060

61-
fig, axes = plt.subplots(ncols=2)
62-
for ax, markers in zip(axes, split_list(Line2D.filled_markers)):
61+
fig, axs = plt.subplots(ncols=2)
62+
for ax, markers in zip(axs, split_list(Line2D.filled_markers)):
6363
for y, marker in enumerate(markers):
6464
ax.text(-0.5, y, repr(marker), **text_style)
6565
ax.plot(y * points, marker=marker, **marker_style)

‎examples/lines_bars_and_markers/spectrum_demo.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/spectrum_demo.py
+14-14Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@
2525

2626
s = 0.1 * np.sin(4 * np.pi * t) + cnse # the signal
2727

28-
fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(7, 7))
28+
fig, axs = plt.subplots(nrows=3, ncols=2, figsize=(7, 7))
2929

3030
# plot time signal:
31-
axes[0, 0].set_title("Signal")
32-
axes[0, 0].plot(t, s, color='C0')
33-
axes[0, 0].set_xlabel("Time")
34-
axes[0, 0].set_ylabel("Amplitude")
31+
axs[0, 0].set_title("Signal")
32+
axs[0, 0].plot(t, s, color='C0')
33+
axs[0, 0].set_xlabel("Time")
34+
axs[0, 0].set_ylabel("Amplitude")
3535

3636
# plot different spectrum types:
37-
axes[1, 0].set_title("Magnitude Spectrum")
38-
axes[1, 0].magnitude_spectrum(s, Fs=Fs, color='C1')
37+
axs[1, 0].set_title("Magnitude Spectrum")
38+
axs[1, 0].magnitude_spectrum(s, Fs=Fs, color='C1')
3939

40-
axes[1, 1].set_title("Log. Magnitude Spectrum")
41-
axes[1, 1].magnitude_spectrum(s, Fs=Fs, scale='dB', color='C1')
40+
axs[1, 1].set_title("Log. Magnitude Spectrum")
41+
axs[1, 1].magnitude_spectrum(s, Fs=Fs, scale='dB', color='C1')
4242

43-
axes[2, 0].set_title("Phase Spectrum ")
44-
axes[2, 0].phase_spectrum(s, Fs=Fs, color='C2')
43+
axs[2, 0].set_title("Phase Spectrum ")
44+
axs[2, 0].phase_spectrum(s, Fs=Fs, color='C2')
4545

46-
axes[2, 1].set_title("Angle Spectrum")
47-
axes[2, 1].angle_spectrum(s, Fs=Fs, color='C2')
46+
axs[2, 1].set_title("Angle Spectrum")
47+
axs[2, 1].angle_spectrum(s, Fs=Fs, color='C2')
4848

49-
axes[0, 1].remove() # don't display empty ax
49+
axs[0, 1].remove() # don't display empty ax
5050

5151
fig.tight_layout()
5252
plt.show()

‎examples/scales/power_norm.py

Copy file name to clipboardExpand all lines: examples/scales/power_norm.py
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919

2020
gammas = [0.8, 0.5, 0.3]
2121

22-
fig, axes = plt.subplots(nrows=2, ncols=2)
22+
fig, axs = plt.subplots(nrows=2, ncols=2)
2323

24-
axes[0, 0].set_title('Linear normalization')
25-
axes[0, 0].hist2d(data[:, 0], data[:, 1], bins=100)
24+
axs[0, 0].set_title('Linear normalization')
25+
axs[0, 0].hist2d(data[:, 0], data[:, 1], bins=100)
2626

27-
for ax, gamma in zip(axes.flat[1:], gammas):
27+
for ax, gamma in zip(axs.flat[1:], gammas):
2828
ax.set_title(r'Power law $(\gamma=%1.1f)$' % gamma)
29-
ax.hist2d(data[:, 0], data[:, 1],
30-
bins=100, norm=mcolors.PowerNorm(gamma))
29+
ax.hist2d(data[:, 0], data[:, 1], bins=100, norm=mcolors.PowerNorm(gamma))
3130

3231
fig.tight_layout()
3332

‎examples/shapes_and_collections/collections.py

Copy file name to clipboardExpand all lines: examples/shapes_and_collections/collections.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@
4343
colors = [colors.to_rgba(c)
4444
for c in plt.rcParams['axes.prop_cycle'].by_key()['color']]
4545

46-
fig, axes = plt.subplots(2, 2)
46+
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
4747
fig.subplots_adjust(top=0.92, left=0.07, right=0.97,
4848
hspace=0.3, wspace=0.3)
49-
((ax1, ax2), (ax3, ax4)) = axes # unpack the axes
5049

5150

5251
col = collections.LineCollection([spiral], offsets=xyo,

‎examples/specialty_plots/radar_chart.py

Copy file name to clipboardExpand all lines: examples/specialty_plots/radar_chart.py
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ def example_data():
162162
data = example_data()
163163
spoke_labels = data.pop(0)
164164

165-
fig, axes = plt.subplots(figsize=(9, 9), nrows=2, ncols=2,
166-
subplot_kw=dict(projection='radar'))
165+
fig, axs = plt.subplots(figsize=(9, 9), nrows=2, ncols=2,
166+
subplot_kw=dict(projection='radar'))
167167
fig.subplots_adjust(wspace=0.25, hspace=0.20, top=0.85, bottom=0.05)
168168

169169
colors = ['b', 'r', 'g', 'm', 'y']
170170
# Plot the four cases from the example data on separate axes
171-
for ax, (title, case_data) in zip(axes.flat, data):
171+
for ax, (title, case_data) in zip(axs.flat, data):
172172
ax.set_rgrids([0.2, 0.4, 0.6, 0.8])
173173
ax.set_title(title, weight='bold', size='medium', position=(0.5, 1.1),
174174
horizontalalignment='center', verticalalignment='center')
@@ -178,10 +178,9 @@ def example_data():
178178
ax.set_varlabels(spoke_labels)
179179

180180
# add legend relative to top-left plot
181-
ax = axes[0, 0]
182181
labels = ('Factor 1', 'Factor 2', 'Factor 3', 'Factor 4', 'Factor 5')
183-
legend = ax.legend(labels, loc=(0.9, .95),
184-
labelspacing=0.1, fontsize='small')
182+
legend = axs[0, 0].legend(labels, loc=(0.9, .95),
183+
labelspacing=0.1, fontsize='small')
185184

186185
fig.text(0.5, 0.965, '5-Factor Solution Profiles Across Four Scenarios',
187186
horizontalalignment='center', color='black', weight='bold',

‎examples/specialty_plots/topographic_hillshading.py

Copy file name to clipboardExpand all lines: examples/specialty_plots/topographic_hillshading.py
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
ls = LightSource(azdeg=315, altdeg=45)
4545
cmap = plt.cm.gist_earth
4646

47-
fig, axes = plt.subplots(nrows=4, ncols=3, figsize=(8, 9))
48-
plt.setp(axes.flat, xticks=[], yticks=[])
47+
fig, axs = plt.subplots(nrows=4, ncols=3, figsize=(8, 9))
48+
plt.setp(axs.flat, xticks=[], yticks=[])
4949

5050
# Vary vertical exaggeration and blend mode and plot all combinations
51-
for col, ve in zip(axes.T, [0.1, 1, 10]):
51+
for col, ve in zip(axs.T, [0.1, 1, 10]):
5252
# Show the hillshade intensity image in the first row
5353
col[0].imshow(ls.hillshade(z, vert_exag=ve, dx=dx, dy=dy), cmap='gray')
5454

@@ -59,18 +59,18 @@
5959
ax.imshow(rgb)
6060

6161
# Label rows and columns
62-
for ax, ve in zip(axes[0], [0.1, 1, 10]):
62+
for ax, ve in zip(axs[0], [0.1, 1, 10]):
6363
ax.set_title('{0}'.format(ve), size=18)
64-
for ax, mode in zip(axes[:, 0], ['Hillshade', 'hsv', 'overlay', 'soft']):
64+
for ax, mode in zip(axs[:, 0], ['Hillshade', 'hsv', 'overlay', 'soft']):
6565
ax.set_ylabel(mode, size=18)
6666

6767
# Group labels...
68-
axes[0, 1].annotate('Vertical Exaggeration', (0.5, 1), xytext=(0, 30),
69-
textcoords='offset points', xycoords='axes fraction',
70-
ha='center', va='bottom', size=20)
71-
axes[2, 0].annotate('Blend Mode', (0, 0.5), xytext=(-30, 0),
72-
textcoords='offset points', xycoords='axes fraction',
73-
ha='right', va='center', size=20, rotation=90)
68+
axs[0, 1].annotate('Vertical Exaggeration', (0.5, 1), xytext=(0, 30),
69+
textcoords='offset points', xycoords='axes fraction',
70+
ha='center', va='bottom', size=20)
71+
axs[2, 0].annotate('Blend Mode', (0, 0.5), xytext=(-30, 0),
72+
textcoords='offset points', xycoords='axes fraction',
73+
ha='right', va='center', size=20, rotation=90)
7474
fig.subplots_adjust(bottom=0.05, right=0.95)
7575

7676
plt.show()

‎examples/statistics/boxplot.py

Copy file name to clipboardExpand all lines: examples/statistics/boxplot.py
+30-30Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@
2828
###############################################################################
2929
# Demonstrate how to toggle the display of different elements:
3030

31-
fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(6, 6), sharey=True)
32-
axes[0, 0].boxplot(data, labels=labels)
33-
axes[0, 0].set_title('Default', fontsize=fs)
31+
fig, axs = plt.subplots(nrows=2, ncols=3, figsize=(6, 6), sharey=True)
32+
axs[0, 0].boxplot(data, labels=labels)
33+
axs[0, 0].set_title('Default', fontsize=fs)
3434

35-
axes[0, 1].boxplot(data, labels=labels, showmeans=True)
36-
axes[0, 1].set_title('showmeans=True', fontsize=fs)
35+
axs[0, 1].boxplot(data, labels=labels, showmeans=True)
36+
axs[0, 1].set_title('showmeans=True', fontsize=fs)
3737

38-
axes[0, 2].boxplot(data, labels=labels, showmeans=True, meanline=True)
39-
axes[0, 2].set_title('showmeans=True,\nmeanline=True', fontsize=fs)
38+
axs[0, 2].boxplot(data, labels=labels, showmeans=True, meanline=True)
39+
axs[0, 2].set_title('showmeans=True,\nmeanline=True', fontsize=fs)
4040

41-
axes[1, 0].boxplot(data, labels=labels, showbox=False, showcaps=False)
41+
axs[1, 0].boxplot(data, labels=labels, showbox=False, showcaps=False)
4242
tufte_title = 'Tufte Style \n(showbox=False,\nshowcaps=False)'
43-
axes[1, 0].set_title(tufte_title, fontsize=fs)
43+
axs[1, 0].set_title(tufte_title, fontsize=fs)
4444

45-
axes[1, 1].boxplot(data, labels=labels, notch=True, bootstrap=10000)
46-
axes[1, 1].set_title('notch=True,\nbootstrap=10000', fontsize=fs)
45+
axs[1, 1].boxplot(data, labels=labels, notch=True, bootstrap=10000)
46+
axs[1, 1].set_title('notch=True,\nbootstrap=10000', fontsize=fs)
4747

48-
axes[1, 2].boxplot(data, labels=labels, showfliers=False)
49-
axes[1, 2].set_title('showfliers=False', fontsize=fs)
48+
axs[1, 2].boxplot(data, labels=labels, showfliers=False)
49+
axs[1, 2].set_title('showfliers=False', fontsize=fs)
5050

51-
for ax in axes.flat:
51+
for ax in axs.flat:
5252
ax.set_yscale('log')
5353
ax.set_yticklabels([])
5454

@@ -67,28 +67,28 @@
6767
markerfacecolor='firebrick')
6868
meanlineprops = dict(linestyle='--', linewidth=2.5, color='purple')
6969

70-
fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(6, 6), sharey=True)
71-
axes[0, 0].boxplot(data, boxprops=boxprops)
72-
axes[0, 0].set_title('Custom boxprops', fontsize=fs)
70+
fig, axs = plt.subplots(nrows=2, ncols=3, figsize=(6, 6), sharey=True)
71+
axs[0, 0].boxplot(data, boxprops=boxprops)
72+
axs[0, 0].set_title('Custom boxprops', fontsize=fs)
7373

74-
axes[0, 1].boxplot(data, flierprops=flierprops, medianprops=medianprops)
75-
axes[0, 1].set_title('Custom medianprops\nand flierprops', fontsize=fs)
74+
axs[0, 1].boxplot(data, flierprops=flierprops, medianprops=medianprops)
75+
axs[0, 1].set_title('Custom medianprops\nand flierprops', fontsize=fs)
7676

77-
axes[0, 2].boxplot(data, whis='range')
78-
axes[0, 2].set_title('whis="range"', fontsize=fs)
77+
axs[0, 2].boxplot(data, whis='range')
78+
axs[0, 2].set_title('whis="range"', fontsize=fs)
7979

80-
axes[1, 0].boxplot(data, meanprops=meanpointprops, meanline=False,
81-
showmeans=True)
82-
axes[1, 0].set_title('Custom mean\nas point', fontsize=fs)
80+
axs[1, 0].boxplot(data, meanprops=meanpointprops, meanline=False,
81+
showmeans=True)
82+
axs[1, 0].set_title('Custom mean\nas point', fontsize=fs)
8383

84-
axes[1, 1].boxplot(data, meanprops=meanlineprops, meanline=True,
85-
showmeans=True)
86-
axes[1, 1].set_title('Custom mean\nas line', fontsize=fs)
84+
axs[1, 1].boxplot(data, meanprops=meanlineprops, meanline=True,
85+
showmeans=True)
86+
axs[1, 1].set_title('Custom mean\nas line', fontsize=fs)
8787

88-
axes[1, 2].boxplot(data, whis=[15, 85])
89-
axes[1, 2].set_title('whis=[15, 85]\n#percentiles', fontsize=fs)
88+
axs[1, 2].boxplot(data, whis=[15, 85])
89+
axs[1, 2].set_title('whis=[15, 85]\n#percentiles', fontsize=fs)
9090

91-
for ax in axes.flat:
91+
for ax in axs.flat:
9292
ax.set_yscale('log')
9393
ax.set_yticklabels([])
9494

‎examples/statistics/boxplot_color.py

Copy file name to clipboardExpand all lines: examples/statistics/boxplot_color.py
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
all_data = [np.random.normal(0, std, size=100) for std in range(1, 4)]
2222
labels = ['x1', 'x2', 'x3']
2323

24-
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(9, 4))
24+
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, figsize=(9, 4))
2525

2626
# rectangular box plot
27-
bplot1 = axes[0].boxplot(all_data,
28-
vert=True, # vertical box alignment
29-
patch_artist=True, # fill with color
30-
labels=labels) # will be used to label x-ticks
31-
axes[0].set_title('Rectangular box plot')
27+
bplot1 = ax1.boxplot(all_data,
28+
vert=True, # vertical box alignment
29+
patch_artist=True, # fill with color
30+
labels=labels) # will be used to label x-ticks
31+
ax1.set_title('Rectangular box plot')
3232

3333
# notch shape box plot
34-
bplot2 = axes[1].boxplot(all_data,
35-
notch=True, # notch shape
36-
vert=True, # vertical box alignment
37-
patch_artist=True, # fill with color
38-
labels=labels) # will be used to label x-ticks
39-
axes[1].set_title('Notched box plot')
34+
bplot2 = ax2.boxplot(all_data,
35+
notch=True, # notch shape
36+
vert=True, # vertical box alignment
37+
patch_artist=True, # fill with color
38+
labels=labels) # will be used to label x-ticks
39+
ax2.set_title('Notched box plot')
4040

4141
# fill with colors
4242
colors = ['pink', 'lightblue', 'lightgreen']
@@ -45,7 +45,7 @@
4545
patch.set_facecolor(color)
4646

4747
# adding horizontal grid lines
48-
for ax in axes:
48+
for ax in [ax1, ax2]:
4949
ax.yaxis.grid(True)
5050
ax.set_xlabel('Three separate samples')
5151
ax.set_ylabel('Observed values')

‎examples/statistics/boxplot_vs_violin.py

Copy file name to clipboardExpand all lines: examples/statistics/boxplot_vs_violin.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import matplotlib.pyplot as plt
2424
import numpy as np
2525

26-
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(9, 4))
26+
fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(9, 4))
2727

2828
# Fixing random state for reproducibility
2929
np.random.seed(19680801)
@@ -33,23 +33,23 @@
3333
all_data = [np.random.normal(0, std, 100) for std in range(6, 10)]
3434

3535
# plot violin plot
36-
axes[0].violinplot(all_data,
37-
showmeans=False,
38-
showmedians=True)
39-
axes[0].set_title('Violin plot')
36+
axs[0].violinplot(all_data,
37+
showmeans=False,
38+
showmedians=True)
39+
axs[0].set_title('Violin plot')
4040

4141
# plot box plot
42-
axes[1].boxplot(all_data)
43-
axes[1].set_title('Box plot')
42+
axs[1].boxplot(all_data)
43+
axs[1].set_title('Box plot')
4444

4545
# adding horizontal grid lines
46-
for ax in axes:
46+
for ax in axs:
4747
ax.yaxis.grid(True)
4848
ax.set_xticks([y + 1 for y in range(len(all_data))])
4949
ax.set_xlabel('Four separate samples')
5050
ax.set_ylabel('Observed values')
5151

5252
# add x-tick labels
53-
plt.setp(axes, xticks=[y + 1 for y in range(len(all_data))],
53+
plt.setp(axs, xticks=[y + 1 for y in range(len(all_data))],
5454
xticklabels=['x1', 'x2', 'x3', 'x4'])
5555
plt.show()

0 commit comments

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