Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2addc5b

Browse files
committed
Use batch ax.set() method
1 parent 30cbdf7 commit 2addc5b

29 files changed

+47
-101
lines changed

examples/animation/animate_decay.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ def data_gen():
2222

2323

2424
def init():
25-
ax.set_ylim(-1.1, 1.1)
26-
ax.set_xlim(0, 10)
25+
ax.set(xlim=(0, 10), ylim=(-1.1, 1.1))
2726
del xdata[:]
2827
del ydata[:]
2928
line.set_data(xdata, ydata)

examples/axisartist/axis_direction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
def setup_axes(fig, pos):
1212
ax = fig.add_subplot(pos, axes_class=axisartist.Axes)
1313

14-
ax.set_ylim(-0.1, 1.5)
15-
ax.set_yticks([0, 1])
14+
ax.set(ylim=(-0.1, 1.5), yticks=[0, 1])
1615

1716
ax.axis[:].set_visible(False)
1817

examples/axisartist/demo_ticklabel_alignment.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,16 @@ def setup_axes(fig, pos):
2323
fig.subplots_adjust(left=0.5, hspace=0.7)
2424

2525
ax = setup_axes(fig, 311)
26-
ax.set_ylabel("ha=right")
27-
ax.set_xlabel("va=baseline")
26+
ax.set(xlabel="va=baseline", ylabel="ha=right")
2827

2928
ax = setup_axes(fig, 312)
3029
ax.axis["left"].major_ticklabels.set_ha("center")
3130
ax.axis["bottom"].major_ticklabels.set_va("top")
32-
ax.set_ylabel("ha=center")
33-
ax.set_xlabel("va=top")
31+
ax.set(xlabel="va=top", ylabel="ha=center")
3432

3533
ax = setup_axes(fig, 313)
3634
ax.axis["left"].major_ticklabels.set_ha("left")
3735
ax.axis["bottom"].major_ticklabels.set_va("bottom")
38-
ax.set_ylabel("ha=left")
39-
ax.set_xlabel("va=bottom")
36+
ax.set(xlabel="va=bottom", ylabel="ha=left")
4037

4138
plt.show()

examples/axisartist/demo_ticklabel_direction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
def setup_axes(fig, pos):
1313
ax = fig.add_subplot(pos, axes_class=axislines.Axes)
14-
ax.set_yticks([0.2, 0.8])
15-
ax.set_xticks([0.2, 0.8])
14+
ax.set(xticks=[0.2, 0.8], yticks=[0.2, 0.8])
1615
return ax
1716

1817

examples/axisartist/simple_axis_direction03.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
def setup_axes(fig, pos):
1313
ax = fig.add_subplot(pos, axes_class=axisartist.Axes)
14-
ax.set_yticks([0.2, 0.8])
15-
ax.set_xticks([0.2, 0.8])
14+
ax.set(xticks=[0.2, 0.8], yticks=[0.2, 0.8])
1615
return ax
1716

1817

examples/event_handling/poly_editor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def on_mouse_move(self, event):
205205
ax.add_patch(poly)
206206
p = PolygonInteractor(ax, poly)
207207

208-
ax.set_title('Click and drag a point to move it')
209-
ax.set_xlim((-2, 2))
210-
ax.set_ylim((-2, 2))
208+
ax.set(xlim=(-2, 2), ylim=(-2, 2),
209+
title='Click and drag a point to move it')
210+
211211
plt.show()

examples/images_contours_and_fields/affine_image.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def do_plot(ax, Z, transform):
4040
x1, x2, y1, y2 = im.get_extent()
4141
ax.plot([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], "y--",
4242
transform=trans_data)
43-
ax.set_xlim(-5, 5)
44-
ax.set_ylim(-4, 4)
43+
ax.set(xlim=(-5, 5), ylim=(-4, 4))
4544

4645

4746
# prepare image and figure

examples/images_contours_and_fields/pcolormesh_grids.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ def _annotate(ax, x, y, title):
4242
# this all gets repeated below:
4343
X, Y = np.meshgrid(x, y)
4444
ax.plot(X.flat, Y.flat, 'o', color='m')
45-
ax.set_xlim(-0.7, 5.2)
46-
ax.set_ylim(-0.7, 3.2)
47-
ax.set_title(title)
45+
ax.set(xlim=(-0.7, 5.2), ylim=(-0.7, 3.2), title=title)
4846

4947
_annotate(ax, x, y, "shading='flat'")
5048

examples/lines_bars_and_markers/eventcollection_demo.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@
5252
ax.add_collection(yevents2)
5353

5454
# set the limits
55-
ax.set_xlim([0, 1])
56-
ax.set_ylim([0, 1])
57-
58-
ax.set_title('line plot with data points')
55+
ax.set(xlim=[0, 1], ylim=[0, 1], title='line plot with data points')
5956

6057
# display the plot
6158
plt.show()

examples/lines_bars_and_markers/markevery_demo.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ def trim_axs(axs, N):
6565
axs = plt.figure(figsize=figsize, constrained_layout=True).subplots(rows, cols)
6666
axs = trim_axs(axs, len(cases))
6767
for ax, case in zip(axs, cases):
68-
ax.set_title('markevery=%s' % str(case))
69-
ax.set_xscale('log')
70-
ax.set_yscale('log')
68+
ax.set(xscale='log', yscale='log', title=f'markevery={case!r}')
7169
ax.plot(x, y, 'o', ls='-', ms=4, markevery=case)
7270

7371
###############################################################################
@@ -79,10 +77,8 @@ def trim_axs(axs, N):
7977
axs = plt.figure(figsize=figsize, constrained_layout=True).subplots(rows, cols)
8078
axs = trim_axs(axs, len(cases))
8179
for ax, case in zip(axs, cases):
82-
ax.set_title('markevery=%s' % str(case))
8380
ax.plot(x, y, 'o', ls='-', ms=4, markevery=case)
84-
ax.set_xlim((6, 6.7))
85-
ax.set_ylim((1.1, 1.7))
81+
ax.set(xlim=(6, 6.7), ylim=(1.1, 1.7), title=f'markevery={case!r}')
8682

8783
# define data for polar plots
8884
r = np.linspace(0, 3.0, 200)
@@ -95,7 +91,7 @@ def trim_axs(axs, N):
9591
rows, cols, subplot_kw={'projection': 'polar'})
9692
axs = trim_axs(axs, len(cases))
9793
for ax, case in zip(axs, cases):
98-
ax.set_title('markevery=%s' % str(case))
94+
ax.set_title(f'markevery={case!r}')
9995
ax.plot(theta, r, 'o', ls='-', ms=4, markevery=case)
10096

10197
plt.show()

0 commit comments

Comments
 (0)