8000 Use (set_)tick_params more internally. · matplotlib/matplotlib@2348584 · GitHub
[go: up one dir, main page]

Skip to content
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 2348584

Browse files
committed
Use (set_)tick_params more internally.
1 parent 2c90227 commit 2348584

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

lib/matplotlib/figure.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,14 +1173,12 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
11731173
if sharex in ["col", "all"]:
11741174
# turn off all but the bottom row
11751175
for ax in axarr[:-1, :].flat:
1176-
for label in ax.get_xticklabels():
1177-
label.set_visible(False)
1176+
ax.xaxis.set_tick_params(labelbottom=False)
11781177
ax.xaxis.offsetText.set_visible(False)
11791178
if sharey in ["row", "all"]:
11801179
# turn off all but the first column
11811180
for ax in axarr[:, 1:].flat:
1182-
for label in ax.get_yticklabels():
1183-
label.set_visible(False)
1181+
ax.yaxis.set_tick_params(labelleft=False)
11841182
ax.yaxis.offsetText.set_visible(False)
11851183

11861184
if squeeze:

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)
0