From e0ddd9b2d91ebda2c06d35dbfe5b5d7001d5aa25 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 12 Jul 2021 00:40:19 +0200 Subject: [PATCH] Use ticklabels([]) instead of ticklabels('') The string variant is not supported according to the docstring. It's only working by accident. --- examples/subplots_axes_and_figures/zoom_inset_axes.py | 4 ++-- examples/text_labels_and_annotations/mathtext_examples.py | 4 ++-- lib/matplotlib/projections/geo.py | 1 + lib/matplotlib/tests/test_constrainedlayout.py | 8 ++++---- lib/matplotlib/tests/test_text.py | 4 ++-- tutorials/intermediate/constrainedlayout_guide.py | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/subplots_axes_and_figures/zoom_inset_axes.py b/examples/subplots_axes_and_figures/zoom_inset_axes.py index e3f99ce3aec9..85f3f78ec6b4 100644 --- a/examples/subplots_axes_and_figures/zoom_inset_axes.py +++ b/examples/subplots_axes_and_figures/zoom_inset_axes.py @@ -33,8 +33,8 @@ def get_demo_image(): x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9 axins.set_xlim(x1, x2) axins.set_ylim(y1, y2) -axins.set_xticklabels('') -axins.set_yticklabels('') +axins.set_xticklabels([]) +axins.set_yticklabels([]) ax.indicate_inset_zoom(axins, edgecolor="black") diff --git a/examples/text_labels_and_annotations/mathtext_examples.py b/examples/text_labels_and_annotations/mathtext_examples.py index 6d8be49599cf..c94d7d25efdd 100644 --- a/examples/text_labels_and_annotations/mathtext_examples.py +++ b/examples/text_labels_and_annotations/mathtext_examples.py @@ -68,8 +68,8 @@ def doall(): plt.gca().set_ylim(0., 1.) plt.gca().set_title("Matplotlib's math rendering engine", color=mpl_grey_rvb, fontsize=14, weight='bold') - plt.gca().set_xticklabels("", visible=False) - plt.gca().set_yticklabels("", visible=False) + plt.gca().set_xticklabels([]) + plt.gca().set_yticklabels([]) # Gap between lines in axes coords line_axesfrac = 1 / n_lines diff --git a/lib/matplotlib/projections/geo.py b/lib/matplotlib/projections/geo.py index 4aa374c5d75d..13b0b63da7e6 100644 --- a/lib/matplotlib/projections/geo.py +++ b/lib/matplotlib/projections/geo.py @@ -147,6 +147,7 @@ def set_yscale(self, *args, **kwargs): set_xscale = set_yscale def set_xlim(self, *args, **kwargs): + """Not supported. Please consider using Cartopy.""" raise TypeError("Changing axes limits of a geographic projection is " "not supported. Please consider using Cartopy.") diff --git a/lib/matplotlib/tests/test_constrainedlayout.py b/lib/matplotlib/tests/test_constrainedlayout.py index 38fa5a765063..0dbf128fc672 100644 --- a/lib/matplotlib/tests/test_constrainedlayout.py +++ b/lib/matplotlib/tests/test_constrainedlayout.py @@ -16,8 +16,8 @@ def example_plot(ax, fontsize=12, nodec=False): ax.set_ylabel('y-label', fontsize=fontsize) ax.set_title('Title', fontsize=fontsize) else: - ax.set_xticklabels('') - ax.set_yticklabels('') + ax.set_xticklabels([]) + ax.set_yticklabels([]) def example_pcolor(ax, fontsize=12): @@ -428,8 +428,8 @@ def test_colorbar_align(): if nn != 1: cb.ax.xaxis.set_ticks([]) cb.ax.yaxis.set_ticks([]) - ax.set_xticklabels('') - ax.set_yticklabels('') + ax.set_xticklabels([]) + ax.set_yticklabels([]) fig.set_constrained_layout_pads(w_pad=4 / 72, h_pad=4 / 72, hspace=0.1, wspace=0.1) diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index abefe3c3ab04..d59b79d15b29 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -636,12 +636,12 @@ def test_large_subscript_title(): ax = axs[0] ax.set_title(r'$\sum_{i} x_i$') ax.set_title('New way', loc='left') - ax.set_xticklabels('') + ax.set_xticklabels([]) ax = axs[1] ax.set_title(r'$\sum_{i} x_i$', y=1.01) ax.set_title('Old Way', loc='left') - ax.set_xticklabels('') + ax.set_xticklabels([]) def test_wrap(): diff --git a/tutorials/intermediate/constrainedlayout_guide.py b/tutorials/intermediate/constrainedlayout_guide.py index fc94f6d14790..2c76c4c0327d 100644 --- a/tutorials/intermediate/constrainedlayout_guide.py +++ b/tutorials/intermediate/constrainedlayout_guide.py @@ -296,8 +296,8 @@ def example_plot(ax, fontsize=12, hide_labels=False): for pad, ax in zip(pads, axs.flat): pc = ax.pcolormesh(arr, **pc_kwargs) fig.colorbar(pc, ax=ax, shrink=0.6, pad=pad) - ax.set_xticklabels('') - ax.set_yticklabels('') + ax.set_xticklabels([]) + ax.set_yticklabels([]) ax.set_title(f'pad: {pad}') fig.set_constrained_layout_pads(w_pad=2 / 72, h_pad=2 / 72, hspace=0.2, wspace=0.2)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: