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

Skip to content

Commit 68b9cdd

Browse files
committed
Use (set_)tick_params more internally.
1 parent 7776c1f commit 68b9cdd

File tree

5 files changed

+12
-22
lines changed

5 files changed

+12
-22
lines changed

lib/matplotlib/figure.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,14 +1145,12 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
11451145
if sharex in ["col", "all"]:
11461146
# turn off all but the bottom row
11471147
for ax in axarr[:-1, :].flat:
1148-
for label in ax.get_xticklabels():
1149-
label.set_visible(False)
1148+
ax.xaxis.set_tick_params(labelbottom=False)
11501149
ax.xaxis.offsetText.set_visible(False)
11511150
if sharey in ["row", "all"]:
11521151
# turn off all but the first column
11531152
for ax in axarr[:, 1:].flat:
1154-
for label in ax.get_yticklabels():
1155-
label.set_visible(False)
1153+
ax.yaxis.set_tick_params(labelleft=False)
11561154
ax.yaxis.offsetText.set_visible(False)
11571155

11581156
if squeeze:

lib/matplotlib/projections/polar.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ def set_thetagrids(self, angles, labels=None, frac=None, fmt=None,
518518
if frac is not None:
519519
self._theta_label1_position.clear().translate(0.0, frac)
520520
self._theta_label2_position.clear().translate(0.0, 1.0 / frac)
521-
for t in self.xaxis.get_ticklabels():
522-
t.update(kwargs)
521+
self.xaxis.set_tick_params(which='major', **kwargs)
523522
return self.xaxis.get_ticklines(), self.xaxis.get_ticklabels()
524523

525524
@docstring.dedent_interpd
@@ -561,8 +560,7 @@ def set_rgrids(self, radii, labels=None, angle=None, fmt=None,
561560
if angle is None:
562561
angle = self.get_rlabel_position()
563562
self.set_rlabel_position(angle)
564-
for t in self.yaxis.get_ticklabels():
565-
t.update(kwargs)
563+
self.yaxis.set_tick_params(which='major', **kwargs)
566564
return self.yaxis.get_gridlines(), self.yaxis.get_ticklabels()
567565

568566
def set_xscale(self, scale, *args, **kwargs):

lib/matplotlib/tests/test_colorbar.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,14 @@ def _colorbar_extension_shape(spacing):
5050
boundaries = values = norm.boundaries
5151
# Create a subplot.
5252
cax = fig.add_subplot(4, 1, i + 1)
53-
# Turn off text and ticks.
54-
for item in cax.get_xticklabels() + cax.get_yticklabels() +\
55-
cax.get_xticklines() + cax.get_yticklines():
56-
item.set_visible(False)
5753
# Generate the colorbar.
5854
cb = ColorbarBase(cax, cmap=cmap, norm=norm,
5955
boundaries=boundaries, values=values,
6056
extend=extension_type, extendrect=True,
6157
orientation='horizontal', spacing=spacing)
58+
# Turn off text and ticks.
59+
cax.tick_params(left=False, labelleft=False,
60+
bottom=False, labelbottom=False)
6261
# Return the figure to the caller.
6362
return fig
6463

@@ -82,15 +81,14 @@ def _colorbar_extension_length(spacing):
8281
for j, extendfrac in enumerate((None, 'auto', 0.1)):
8382
# Create a subplot.
8483
cax = fig.add_subplot(12, 1, i*3 + j + 1)
85-
# Turn off text and ticks.
86-
for item in cax.get_xticklabels() + cax.get_yticklabels() +\
87-
cax.get_xticklines() + cax.get_yticklines():
88-
item.set_visible(False)
8984
# Generate the colorbar.
9085
ColorbarBase(cax, cmap=cmap, norm=norm,
9186
boundaries=boundaries, values=values,
9287
extend=extension_type, extendfrac=extendfrac,
9388
orientation='horizontal', spacing=spacing)
89+
# Turn off text and ticks.
90+
cax.tick_params(left=False, labelleft=False,
91+
bottom=False, labelbottom=False)
9492
# Return the figure to the caller.
9593
return fig
9694

lib/matplotlib/tests/test_colors.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ def test_cmap_and_norm_from_levels_and_colors():
287287
plt.colorbar(m)
288288

289289
# Hide the axes labels (but not the colorbar ones, as they are useful)
290-
for lab in ax.get_xticklabels() + ax.get_yticklabels():
291-
lab.set_visible(False)
290+
ax.tick_params(labelleft=False, labelbottom=False)
292291

293292

294293
def test_cmap_and_norm_from_levels_and_colors2():

lib/matplotlib/tests/test_patheffects.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ def test_patheffect1():
2323
foreground="w"),
2424
path_effects.Normal()])
2525

26-
ax1.grid(True, linestyle="-")
27-
2826
pe = [path_effects.withStroke(linewidth=3, foreground="w")]
29-
for l in ax1.get_xgridlines() + ax1.get_ygridlines():
30-
l.set_path_effects(pe)
27+
ax1.grid(True, linestyle="-", path_effects=pe)
3128

3229

3330
@image_comparison(baseline_images=['patheffect2'], remove_text=True)

0 commit comments

Comments
 (0)