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

Skip to content

Remove deprecated TextWithDash #15950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/api/artist_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
``matplotlib.artist``
*********************

.. inheritance-diagram:: matplotlib.axes._axes.Axes matplotlib.axes._base._AxesBase matplotlib.axis.Axis matplotlib.axis.Tick matplotlib.axis.XAxis matplotlib.axis.XTick matplotlib.axis.YAxis matplotlib.axis.YTick matplotlib.collections.AsteriskPolygonCollection matplotlib.collections.BrokenBarHCollection matplotlib.collections.CircleCollection matplotlib.collections.Collection matplotlib.collections.EllipseCollection matplotlib.collections.EventCollection matplotlib.collections.LineCollection matplotlib.collections.PatchCollection matplotlib.collections.PathCollection matplotlib.collections.PolyCollection matplotlib.collections.QuadMesh matplotlib.collections.RegularPolyCollection matplotlib.collections.StarPolygonCollection matplotlib.collections.TriMesh matplotlib.collections._CollectionWithSizes matplotlib.contour.ClabelText matplotlib.figure.Figure matplotlib.image.AxesImage matplotlib.image.BboxImage matplotlib.image.FigureImage matplotlib.image.NonUniformImage matplotlib.image.PcolorImage matplotlib.image._ImageBase matplotlib.legend.Legend matplotlib.lines.Line2D matplotlib.offsetbox.AnchoredOffsetbox matplotlib.offsetbox.AnchoredText matplotlib.offsetbox.AnnotationBbox matplotlib.offsetbox.AuxTransformBox matplotlib.offsetbox.DrawingArea matplotlib.offsetbox.HPacker matplotlib.offsetbox.OffsetBox matplotlib.offsetbox.OffsetImage matplotlib.offsetbox.PackerBase matplotlib.offsetbox.PaddedBox matplotlib.offsetbox.TextArea matplotlib.offsetbox.VPacker matplotlib.patches.Arc matplotlib.patches.Arrow matplotlib.patches.Circle matplotlib.patches.CirclePolygon matplotlib.patches.ConnectionPatch matplotlib.patches.Ellipse matplotlib.patches.FancyArrow matplotlib.patches.FancyArrowPatch matplotlib.patches.FancyBboxPatch matplotlib.patches.Patch matplotlib.patches.PathPatch matplotlib.patches.Polygon matplotlib.patches.Rectangle matplotlib.patches.RegularPolygon matplotlib.patches.Shadow matplotlib.patches.Wedge matplotlib.projections.geo.AitoffAxes matplotlib.projections.geo.GeoAxes matplotlib.projections.geo.HammerAxes matplotlib.projections.geo.LambertAxes matplotlib.projections.geo.MollweideAxes matplotlib.projections.polar.PolarAxes matplotlib.quiver.Barbs matplotlib.quiver.Quiver matplotlib.quiver.QuiverKey matplotlib.spines.Spine matplotlib.table.Cell matplotlib.table.CustomCell matplotlib.table.Table matplotlib.text.Annotation matplotlib.text.Text matplotlib.text.TextWithDash
.. inheritance-diagram:: matplotlib.axes._axes.Axes matplotlib.axes._base._AxesBase matplotlib.axis.Axis matplotlib.axis.Tick matplotlib.axis.XAxis matplotlib.axis.XTick matplotlib.axis.YAxis matplotlib.axis.YTick matplotlib.collections.AsteriskPolygonCollection matplotlib.collections.BrokenBarHCollection matplotlib.collections.CircleCollection matplotlib.collections.Collection matplotlib.collections.EllipseCollection matplotlib.collections.EventCollection matplotlib.collections.LineCollection matplotlib.collections.PatchCollection matplotlib.collections.PathCollection matplotlib.collections.PolyCollection matplotlib.collections.QuadMesh matplotlib.collections.RegularPolyCollection matplotlib.collections.StarPolygonCollection matplotlib.collections.TriMesh matplotlib.collections._CollectionWithSizes matplotlib.contour.ClabelText matplotlib.figure.Figure matplotlib.image.AxesImage matplotlib.image.BboxImage matplotlib.image.FigureImage matplotlib.image.NonUniformImage matplotlib.image.PcolorImage matplotlib.image._ImageBase matplotlib.legend.Legend matplotlib.lines.Line2D matplotlib.offsetbox.AnchoredOffsetbox matplotlib.offsetbox.AnchoredText matplotlib.offsetbox.AnnotationBbox matplotlib.offsetbox.AuxTransformBox matplotlib.offsetbox.DrawingArea matplotlib.offsetbox.HPacker matplotlib.offsetbox.OffsetBox matplotlib.offsetbox.OffsetImage matplotlib.offsetbox.PackerBase matplotlib.offsetbox.PaddedBox matplotlib.offsetbox.TextArea matplotlib.offsetbox.VPacker matplotlib.patches.Arc matplotlib.patches.Arrow matplotlib.patches.Circle matplotlib.patches.CirclePolygon matplotlib.patches.ConnectionPatch matplotlib.patches.Ellipse matplotlib.patches.FancyArrow matplotlib.patches.FancyArrowPatch matplotlib.patches.FancyBboxPatch matplotlib.patches.Patch matplotlib.patches.PathPatch matplotlib.patches.Polygon matplotlib.patches.Rectangle matplotlib.patches.RegularPolygon matplotlib.patches.Shadow matplotlib.patches.Wedge matplotlib.projections.geo.AitoffAxes matplotlib.projections.geo.GeoAxes matplotlib.projections.geo.HammerAxes matplotlib.projections.geo.LambertAxes matplotlib.projections.geo.MollweideAxes matplotlib.projections.polar.PolarAxes matplotlib.quiver.Barbs matplotlib.quiver.Quiver matplotlib.quiver.QuiverKey matplotlib.spines.Spine matplotlib.table.Cell matplotlib.table.CustomCell matplotlib.table.Table matplotlib.text.Annotation matplotlib.text.Text
:parts: 1
:private-bases:

Expand Down
7 changes: 7 additions & 0 deletions doc/api/next_api_changes/removals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ Classes and methods
- ``colorbar.ColorbarBase.get_clim`` (use ``ScalarMappable.get_clim`` instead)
- ``colorbar.ColorbarBase.set_clim`` (use ``ScalarMappable.set_clim`` instead)
- ``colorbar.ColorbarBase.set_norm`` (use ``ScalarMappable.set_norm`` instead)

- ``text.TextWithDash`` (use ``text.Annotation`` instead)

Arguments
~~~~~~~~~
- ``Axes.text()`` / ``pyplot.text()`` do not support the parameter ``withdash``
anymore. Use ``Axes.annotate()`` and ``pyplot.annotate()`` instead.
2 changes: 1 addition & 1 deletion doc/api/prev_api_changes/api_changes_3.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ This has always returned None instead of the requested radius.
Text
~~~~

- `.text.TextWithDash`
- ``text.TextWithDash``
- `.Text.is_math_text`
- `.TextPath.is_math_text`
- `.TextPath.text_get_vertices_codes` (As an alternative, construct a new ``TextPath`` object.)
Expand Down
46 changes: 0 additions & 46 deletions examples/text_labels_and_annotations/dashpointlabel.py

This file was deleted.

3 changes: 1 addition & 2 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
defines classes for drawing polygons

:mod:`matplotlib.text`
defines the :class:`~matplotlib.text.Text`,
:class:`~matplotlib.text.TextWithDash`, and
defines the :class:`~matplotlib.text.Text` and
:class:`~matplotlib.text.Annotate` classes

:mod:`matplotlib.image`
Expand Down
28 changes: 3 additions & 25 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,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):
def text(self, x, y, s, fontdict=None, **kwargs):
"""
Add text to the axes.

Expand All @@ -671,10 +670,6 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):
A dictionary to override the default text properties. If fontdict
is None, the defaults are determined by your rc parameters.

withdash : bool, default: False
Creates a `~matplotlib.text.TextWithDash` instance instead of a
`~matplotlib.text.Text` instance.

Returns
-------
text : `.Text`
Expand Down Expand Up @@ -707,32 +702,15 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):

>>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5))
"""
if fontdict is None:
fontdict = {}

effective_kwargs = {
'verticalalignment': 'baseline',
'horizontalalignment': 'left',
'transform': self.transData,
'clip_on': False,
**fontdict,
**(fontdict if fontdict is not None else {}),
**kwargs,
}

# At some point if we feel confident that TextWithDash
# is robust as a drop-in replacement for Text and that
# the performance impact of the heavier-weight class
# isn't too significant, it may make sense to eliminate
# the withdash kwarg and simply delegate whether there's
# a dash to TextWithDash and dashlength.

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)
t.update(effective_kwargs)

t = mtext.Text(x, y, text=s, **effective_kwargs)
t.set_clip_path(self.patch)
self._add_text(t)
return t
Expand Down
28 changes: 8 additions & 20 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import matplotlib.legend as mlegend
from matplotlib.patches import Rectangle
from matplotlib.projections import process_projection_requirements
from matplotlib.text import Text, TextWithDash
from matplotlib.text import Text
from matplotlib.transforms import (Affine2D, Bbox, BboxTransformTo,
TransformedBbox)
import matplotlib._layoutbox as layoutbox
Expand Down Expand Up @@ -1821,9 +1821,8 @@ 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):
def text(self, x, y, s, fontdict=None, **kwargs):
"""
Add text to figure.

Expand All @@ -1843,10 +1842,6 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):
passed as *kwargs* override the corresponding ones given in
*fontdict*.

withdash : bool, default: False
Creates a `~matplotlib.text.TextWithDash` instance instead of a
`~matplotlib.text.Text` instance.

Other Parameters
----------------
**kwargs : `~matplotlib.text.Text` properties
Expand All @@ -1863,19 +1858,12 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):
.Axes.text
.pyplot.text
"""
default = dict(transform=self.transFigure)

if (withdash
and withdash is not cbook.deprecation._deprecated_parameter):
text = TextWithDash(x=x, y=y, text=s)
else:
text = Text(x=x, y=y, text=s)

text.update(default)
if fontdict is not None:
text.update(fontdict)
text.update(kwargs)

effective_kwargs = {
'transform': self.transFigure,
**(fontdict if fontdict is not None else {}),
**kwargs,
}
text = Text(x=x, y=y, text=s, **effective_kwargs)
text.set_figure(self)
text.stale_callback = _stale_figure_callback

Expand Down
13 changes: 4 additions & 9 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2096,11 +2096,8 @@ def figimage(

# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@docstring.copy(Figure.text)
def figtext(
x, y, s, fontdict=None,
withdash=cbook.deprecation._deprecated_parameter, **kwargs):
return gcf().text(
x, y, s, fontdict=fontdict, withdash=withdash, **kwargs)
def figtext(x, y, s, fontdict=None, **kwargs):
return gcf().text(x, y, s, fontdict=fontdict, **kwargs)


# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
Expand Down Expand Up @@ -2737,10 +2734,8 @@ 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=cbook.deprecation._deprecated_parameter, **kwargs):
return gca().text(x, y, s, fontdict=fontdict, withdash=withdash, **kwargs)
def text(x, y, s, fontdict=None, **kwargs):
return gca().text(x, y, s, fontdict=fontdict, **kwargs)


# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
Expand Down
Loading