diff --git a/doc/api/next_api_changes/2019-03-01-AL.rst b/doc/api/next_api_changes/2019-03-01-AL.rst new file mode 100644 index 000000000000..82dea08422d1 --- /dev/null +++ b/doc/api/next_api_changes/2019-03-01-AL.rst @@ -0,0 +1,5 @@ +Deprecations +```````````` + +The ``text.TextWithDash`` class and the ``withdash`` keyword argument to +``text()`` is deprecated. Consider using ``annotate()`` instead. diff --git a/examples/text_labels_and_annotations/dashpointlabel.py b/examples/text_labels_and_annotations/dashpointlabel.py index b795c70e6414..96a8b7564613 100644 --- a/examples/text_labels_and_annotations/dashpointlabel.py +++ b/examples/text_labels_and_annotations/dashpointlabel.py @@ -4,8 +4,13 @@ =============== """ + +import warnings + import matplotlib.pyplot as plt +warnings.simplefilter("ignore") # Ignore deprecation of withdash. + DATA = ((1, 3), (2, 4), (3, 1), @@ -36,5 +41,6 @@ ax.set_xlim((0, 5)) ax.set_ylim((0, 5)) +ax.set(title="NOTE: The withdash parameter is deprecated.") plt.show() diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index c074ffc43e05..cc38ee8a7cb9 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -673,6 +673,7 @@ def secondary_yaxis(self, location, *, functions=None, **kwargs): raise ValueError('secondary_yaxis location must be either ' 'a float or "left"/"right"') + @cbook._delete_parameter("3.1", "withdash") def text(self, x, y, s, fontdict=None, withdash=False, **kwargs): """ Add text to the axes. @@ -748,7 +749,8 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs): # the withdash kwarg and simply delegate whether there's # a dash to TextWithDash and dashlength. - if withdash: + if (withdash + and withdash is not cbook.deprecation._deprecated_parameter): t = mtext.TextWithDash(x, y, text=s) else: t = mtext.Text(x, y, text=s) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 6919dbf1c4f5..653455b0b6dd 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1804,6 +1804,7 @@ def legend(self, *args, **kwargs): self.stale = True return l + @cbook._delete_parameter("3.1", "withdash") @docstring.dedent_interpd def text(self, x, y, s, fontdict=None, withdash=False, **kwargs): """ diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index ecf84248c1da..9f7b640e62ca 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2936,7 +2936,9 @@ def table( # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy(Axes.text) -def text(x, y, s, fontdict=None, withdash=False, **kwargs): +def text( + x, y, s, fontdict=None, + withdash=cbook.deprecation._deprecated_parameter, **kwargs): return gca().text(x, y, s, fontdict=fontdict, withdash=withdash, **kwargs) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 3ceffaf3777a..81222d0b42d9 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -1245,6 +1245,7 @@ def set_fontname(self, fontname): docstring.dedent_interpd(Text.__init__) +@cbook.deprecated("3.1", alternative="Annotation") class TextWithDash(Text): """ This is basically a :class:`~matplotlib.text.Text` with a dash