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

Skip to content

Commit 8b033a8

Browse files
committed
Deprecate TextWithDash.
TextWithDash appears to be an ancestral version of Annotation that was added over two commits in 2005 (6a4d343, fe80816), revised once in 2006 and another time in 2008, and never touched since then. While it "works", its implementation is 400 lines long, it is only mentioned by a single example (dashpointlabel.py), somewhat complicates Axes.text(), and is likely rarely used and replaceable by Annotation for most use cases. Hence, deprecate it, keeping open the option to undeprecate if this turns out to be too disruptive.
1 parent 2208665 commit 8b033a8

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
The ``text.TextWithDash`` class and the ``withdash`` keyword argument to
5+
``text()`` is deprecated. Consider using ``annotate()`` instead.

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ def secondary_yaxis(self, location, *, functions=None, **kwargs):
673673
raise ValueError('secondary_yaxis location must be either '
674674
'a float or "left"/"right"')
675675

676+
@cbook._delete_parameter("3.1", "withdash")
676677
def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):
677678
"""
678679
Add text to the axes.

lib/matplotlib/figure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,7 @@ def legend(self, *args, **kwargs):
18041804
self.stale = True
18051805
return l
18061806

1807+
@cbook._delete_parameter("3.1", "withdash")
18071808
@docstring.dedent_interpd
18081809
def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):
18091810
"""

lib/matplotlib/pyplot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2936,7 +2936,9 @@ def table(
29362936

29372937
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
29382938
@docstring.copy(Axes.text)
2939-
def text(x, y, s, fontdict=None, withdash=False, **kwargs):
2939+
def text(
2940+
x, y, s, fontdict=None,
2941+
withdash=cbook.deprecation._deprecated_parameter, **kwargs):
29402942
return gca().text(x, y, s, fontdict=fontdict, withdash=withdash, **kwargs)
29412943

29422944

lib/matplotlib/text.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ def set_fontname(self, fontname):
12451245
docstring.dedent_interpd(Text.__init__)
12461246

12471247

1248+
@cbook.deprecated("3.1", alternative="Annotation")
12481249
class TextWithDash(Text):
12491250
"""
12501251
This is basically a :class:`~matplotlib.text.Text` with a dash

0 commit comments

Comments
 (0)