8000 Name Axes variables ax instead of a · matplotlib/matplotlib@d4ec083 · GitHub
[go: up one dir, main page]

Skip to content

Commit d4ec083

Browse files
committed
Name Axes variables ax instead of a
1 parent eb18cb2 commit d4ec083

File tree

9 files changed

+44
-44
lines changed

9 files changed

+44
-44
lines changed

examples/shapes_and_collections/ellipse_demo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@
4545
delta = 45.0 # degrees
4646

4747
angles = np.arange(0, 360 + delta, delta)
48-
ells = [Ellipse((1, 1), 4, 2, a) for a in angles]
48+
ellipses = [Ellipse((1, 1), 4, 2, a) for a in angles]
4949

50-
a = plt.subplot(111, aspect='equal')
50+
ax = plt.subplot(111, aspect='equal')
5151

52-
for e in ells:
53-
e.set_clip_box(a.bbox)
54-
e.set_alpha(0.1)
55-
a.add_artist(e)
52+
for ellipse in ellipses:
53+
ellipse.set_clip_box(ax.bbox)
54+
ellipse.set_alpha(0.1)
55+
ax.add_artist(ellipse)
5656

5757
plt.xlim(-2, 4)
5858
plt.ylim(-1, 3)

examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
win.set_default_size(400, 300)
2323
win.set_title("Embedding in GTK")
2424

25-
f = Figure(figsize=(5, 4), dpi=100)
26-
a = f.add_subplot(1, 1, 1)
25+
fig = Figure(figsize=(5, 4), dpi=100)
26+
ax = fig.add_subplot(1, 1, 1)
2727
t = np.arange(0.0, 3.0, 0.01)
2828
s = np.sin(2*np.pi*t)
29-
a.plot(t, s)
29+
ax.plot(t, s)
3030

3131
vbox = Gtk.VBox()
3232
win.add(vbox)
3333

3434
# Add canvas to vbox
35-
canvas = FigureCanvas(f) # a Gtk.DrawingArea
35+
canvas = FigureCanvas(fig) # a Gtk.DrawingArea
3636
vbox.pack_start(canvas, True, True, 0)
3737

3838
# Create toolbar

examples/user_interfaces/embedding_in_gtk3_sgskip.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
win.set_default_size(400, 300)
2222
win.set_title("Embedding in GTK")
2323

24-
f = Figure(figsize=(5, 4), dpi=100)
25-
a = f.add_subplot(111)
24+
fig = Figure(figsize=(5, 4), dpi=100)
25+
ax = fig.add_subplot(111)
2626
t = np.arange(0.0, 3.0, 0.01)
2727
s = np.sin(2*np.pi*t)
28-
a.plot(t, s)
28+
ax.plot(t, s)
2929

3030
sw = Gtk.ScrolledWindow()
3131
win.add(sw)

examples/user_interfaces/embedding_in_wx3_sgskip.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ def __init__(self, parent):
5757
self.Fit()
5858

5959
def init_plot_data(self):
60-
a = self.fig.add_subplot(111)
60+
ax = self.fig.add_subplot(111)
6161

6262
x = np.arange(120.0) * 2 * np.pi / 60.0
6363
y = np.arange(100.0) * 2 * np.pi / 50.0
6464
self.x, self.y = np.meshgrid(x, y)
6565
z = np.sin(self.x) + np.cos(self.y)
66-
self.im = a.imshow(z, cmap=cm.RdBu)
66+
self.im = ax.imshow(z, cmap=cm.RdBu)
6767

6868
zmax = np.max(z) - ERR_TOL
6969
ymax_i, xmax_i = np.nonzero(z >= zmax)
7070
if self.im.origin == 'upper':
7171
ymax_i = z.shape[0] - ymax_i
72-
self.lines = a.plot(xmax_i, ymax_i, 'ko')
72+
self.lines = ax.plot(xmax_i, ymax_i, 'ko')
7373

7474
self.toolbar.update() # Not sure why this is needed - ADS
7575

examples/user_interfaces/embedding_webagg_sgskip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ def create_figure():
3838
Creates a simple example figure.
3939
"""
4040
fig = Figure()
41-
a = fig.add_subplot(111)
41+
ax = fig.add_subplot(111)
4242
t = np.arange(0.0, 3.0, 0.01)
4343
s = np.sin(2 * np.pi * t)
44-
a.plot(t, s)
44+
ax.plot(t, s)
4545
return fig
4646

4747

lib/matplotlib/figure.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,8 @@ def add_subplot(self, *args, **kwargs):
13581358

13591359
if isinstance(args[0], SubplotBase):
13601360

1361-
a = args[0]
1362-
if a.get_figure() is not self:
1361+
ax = args[0]
1362+
if ax.get_figure() is not self:
13631363
raise ValueError(
13641364
"The Subplot must have been created in the present figure")
13651365
# make a key for the subplot (which includes the axes object id
@@ -1385,9 +1385,9 @@ def add_subplot(self, *args, **kwargs):
13851385
# more similar to add_axes.
13861386
self._axstack.remove(ax)
13871387

1388-
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
1388+
ax = subplot_class_factory(projection_class)(self, *args, **kwargs)
13891389

1390-
return self._add_axes_internal(key, a)
1390+
return self._add_axes_internal(key, ax)
13911391

13921392
def _add_axes_internal(self, key, ax):
13931393
"""Private helper for `add_axes` and `add_subplot`."""

lib/matplotlib/pyplot.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -961,18 +961,18 @@ def subplot(*args, **kwargs):
961961
"and/or 'nrows'. Did you intend to call subplots()?")
962962

963963
fig = gcf()
964-
a = fig.add_subplot(*args, **kwargs)
965-
bbox = a.bbox
964+
ax = fig.add_subplot(*args, **kwargs)
965+
bbox = ax.bbox
966966
byebye = []
967967
for other in fig.axes:
968-
if other == a:
968+
if other == ax:
969969
continue
970970
if bbox.fully_overlaps(other.bbox):
971971
byebye.append(other)
972-
for ax in byebye:
973-
delaxes(ax)
972+
for ax_i in byebye:
973+
delaxes(ax_i)
974974

975-
return a
975+
return ax
976976

977977

978978
def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
@@ -1151,18 +1151,18 @@ def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs):
11511151
subplotspec = GridSpec(s1, s2).new_subplotspec(loc,
11521152
rowspan=rowspan,
11531153
colspan=colspan)
1154-
a = fig.add_subplot(subplotspec, **kwargs)
1155-
bbox = a.bbox
1154+
ax = fig.add_subplot(subplotspec, **kwargs)
1155+
bbox = ax.bbox
11561156
byebye = []
11571157
for other in fig.axes:
1158-
if other == a:
1158+
if other == ax:
11591159
continue
11601160
if bbox.fully_overlaps(other.bbox):
11611161
byebye.append(other)
1162-
for ax in byebye:
1163-
delaxes(ax)
1162+
for ax_i in byebye:
1163+
delaxes(ax_i)
11641164

1165-
return a
1165+
return ax
11661166

11671167

11681168
def twinx(ax=None):

lib/matplotlib/tests/test_collections.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def generate_EventCollection_plot():
3838
)
3939

4040
fig = plt.figure()
41-
splt = fig.add_subplot(1, 1, 1)
42-
splt.add_collection(coll)
43-
splt.set_title('EventCollection: default')
41+
ax = fig.add_subplot(1, 1, 1)
42+
ax.add_collection(coll)
43+
ax.set_title('EventCollection: default')
4444
props = {'positions': positions,
4545
'extra_positions': extra_positions,
4646
'orientation': orientation,
@@ -51,9 +51,9 @@ def generate_EventCollection_plot():
5151
'linestyle': linestyle,
5252
'antialiased': antialiased
5353
}
54-
splt.set_xlim(-1, 22)
55-
splt.set_ylim(0, 2)
56-
return splt, coll, props
54+
ax.set_xlim(-1, 22)
55+
ax.set_ylim(0, 2)
56+
return ax, coll, props
5757

5858

5959
@image_comparison(['EventCollection_plot__default'])

tutorials/introductory/images.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@
214214
###############################################################################
215215
# You can also specify the clim using the returned object
216216
fig = plt.figure() 1CF5
217-
a = fig.add_subplot(1, 2, 1)
217+
ax = fig.add_subplot(1, 2, 1)
218218
imgplot = plt.imshow(lum_img)
219-
a.set_title('Before')
219+
ax.set_title('Before')
220220
plt.colorbar(ticks=[0.1, 0.3, 0.5, 0.7], orientation='horizontal')
221-
a = fig.add_subplot(1, 2, 2)
221+
ax = fig.add_subplot(1, 2, 2)
222222
imgplot = plt.imshow(lum_img)
223223
imgplot.set_clim(0.0, 0.7)
224-
a.set_title('After')
224+
ax.set_title('After')
225225
plt.colorbar(ticks=[0.1, 0.3, 0.5, 0.7], orientation='horizontal')
226226

227227
###############################################################################

0 commit comments

Comments
 (0)
0