From ba4a29e08b4231c3bc4d325cf0dc93db4dda950e Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 16 Dec 2019 20:47:05 +0100 Subject: [PATCH] Remove deprecated TextWithDash --- doc/api/artist_api.rst | 2 +- doc/api/next_api_changes/removals.rst | 7 + .../prev_api_changes/api_changes_3.1.0.rst | 2 +- .../dashpointlabel.py | 46 -- lib/matplotlib/__init__.py | 3 +- lib/matplotlib/axes/_axes.py | 28 +- lib/matplotlib/figure.py | 28 +- lib/matplotlib/pyplot.py | 13 +- lib/matplotlib/text.py | 404 +----------------- 9 files changed, 27 insertions(+), 506 deletions(-) delete mode 100644 examples/text_labels_and_annotations/dashpointlabel.py diff --git a/doc/api/artist_api.rst b/doc/api/artist_api.rst index 85e8edb76f2f..184a16d4be61 100644 --- a/doc/api/artist_api.rst +++ b/doc/api/artist_api.rst @@ -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: diff --git a/doc/api/next_api_changes/removals.rst b/doc/api/next_api_changes/removals.rst index a7df81f97a5b..363aff7369e6 100644 --- a/doc/api/next_api_changes/removals.rst +++ b/doc/api/next_api_changes/removals.rst @@ -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. \ No newline at end of file diff --git a/doc/api/prev_api_changes/api_changes_3.1.0.rst b/doc/api/prev_api_changes/api_changes_3.1.0.rst index 1d823e7ec7b8..22553107b7f5 100644 --- a/doc/api/prev_api_changes/api_changes_3.1.0.rst +++ b/doc/api/prev_api_changes/api_changes_3.1.0.rst @@ -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.) diff --git a/examples/text_labels_and_annotations/dashpointlabel.py b/examples/text_labels_and_annotations/dashpointlabel.py deleted file mode 100644 index 96a8b7564613..000000000000 --- a/examples/text_labels_and_annotations/dashpointlabel.py +++ /dev/null @@ -1,46 +0,0 @@ -""" -=============== -Dashpoint Label -=============== - -""" - -import warnings - -import matplotlib.pyplot as plt - -warnings.simplefilter("ignore") # Ignore deprecation of withdash. - -DATA = ((1, 3), - (2, 4), - (3, 1), - (4, 2)) -# dash_style = -# direction, length, (text)rotation, dashrotation, push -# (The parameters are varied to show their effects, not for visual appeal). -dash_style = ( - (0, 20, -15, 30, 10), - (1, 30, 0, 15, 10), - (0, 40, 15, 15, 10), - (1, 20, 30, 60, 10)) - -fig, ax = plt.subplots() - -(x, y) = zip(*DATA) -ax.plot(x, y, marker='o') -for i in range(len(DATA)): - (x, y) = DATA[i] - (dd, dl, r, dr, dp) = dash_style[i] - t = ax.text(x, y, str((x, y)), withdash=True, - dashdirection=dd, - dashlength=dl, - rotation=r, - dashrotation=dr, - dashpush=dp, - ) - -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/__init__.py b/lib/matplotlib/__init__.py index 7f0d93b1e32e..5b24e61c77a9 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -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` diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index afabd7ec0f51..5c34d2fc04b3 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -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. @@ -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` @@ -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 diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 2fac54b8f5a8..36a3d3253212 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -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 @@ -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. @@ -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 @@ -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 diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index f39cc1332069..f8be6fb87dde 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -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. @@ -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. diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 53ca7933a107..2502527c7f39 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -494,7 +494,7 @@ def update_bbox_position_size(self, renderer): trans = self.get_transform() # don't use self.get_unitless_position here, which refers to text - # position in Text, and dash position in TextWithDash: + # position in Text: posx = float(self.convert_xunits(self._x)) posy = float(self.convert_yunits(self._y)) @@ -686,7 +686,7 @@ def draw(self, renderer): trans = textobj.get_transform() # don't use textobj.get_position here, which refers to text - # position in Text, and dash position in TextWithDash: + # position in Text: posx = float(textobj.convert_xunits(textobj._x)) posy = float(textobj.convert_yunits(textobj._y)) posx, posy = trans.transform((posx, posy)) @@ -1266,406 +1266,6 @@ 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 - (drawn with a :class:`~matplotlib.lines.Line2D`) before/after - it. It is intended to be a drop-in replacement for - :class:`~matplotlib.text.Text`, and should behave identically to - it when *dashlength* = 0.0. - - The dash always comes between the point specified by - :meth:`~matplotlib.text.Text.set_position` and the text. When a - dash exists, the text alignment arguments (*horizontalalignment*, - *verticalalignment*) are ignored. - - *dashlength* is the length of the dash in canvas units. - (default = 0.0). - - *dashdirection* is one of 0 or 1, where 0 draws the dash after the - text and 1 before. (default = 0). - - *dashrotation* specifies the rotation of the dash, and should - generally stay *None*. In this case - :meth:`~matplotlib.text.TextWithDash.get_dashrotation` returns - :meth:`~matplotlib.text.Text.get_rotation`. (i.e., the dash takes - its rotation from the text's rotation). Because the text center is - projected onto the dash, major deviations in the rotation cause - what may be considered visually unappealing results. - (default = *None*) - - *dashpad* is a padding length to add (or subtract) space - between the text and the dash, in canvas units. - (default = 3) - - *dashpush* "pushes" the dash and text away from the point - specified by :meth:`~matplotlib.text.Text.set_position` by the - amount in canvas units. (default = 0) - - .. note:: - - The alignment of the two objects is based on the bounding box - of the :class:`~matplotlib.text.Text`, as obtained by - :meth:`~matplotlib.artist.Artist.get_window_extent`. This, in - turn, appears to depend on the font metrics as given by the - rendering backend. Hence the quality of the "centering" of the - label text with respect to the dash varies depending on the - backend used. - - .. note:: - - I'm not sure that I got the - :meth:`~matplotlib.text.TextWithDash.get_window_extent` right, - or whether that's sufficient for providing the object bounding - box. - - """ - __name__ = 'textwithdash' - - def __str__(self): - return "TextWithDash(%g, %g, %r)" % (self._x, self._y, self._text) - - def __init__(self, - x=0, y=0, text='', - color=None, # defaults to rc params - verticalalignment='center', - horizontalalignment='center', - multialignment=None, - fontproperties=None, # defaults to FontProperties() - rotation=None, - linespacing=None, - dashlength=0.0, - dashdirection=0, - dashrotation=None, - dashpad=3, - dashpush=0, - ): - - Text.__init__(self, x=x, y=y, text=text, color=color, - verticalalignment=verticalalignment, - horizontalalignment=horizontalalignment, - multialignment=multialignment, - fontproperties=fontproperties, - rotation=rotation, - linespacing=linespacing, - ) - - # The position (x, y) values for text and dashline - # are bogus as given in the instantiation; they will - # be set correctly by update_coords() in draw() - - self.dashline = Line2D(xdata=(x, x), - ydata=(y, y), - color='k', - linestyle='-') - - self._dashx = float(x) - self._dashy = float(y) - self._dashlength = dashlength - self._dashdirection = dashdirection - self._dashrotation = dashrotation - self._dashpad = dashpad - self._dashpush = dashpush - - #self.set_bbox(dict(pad=0)) - - def get_unitless_position(self): - "Return the unitless position of the text as a tuple (*x*, *y*)" - # This will get the position with all unit information stripped away. - # This is here for convenience since it is done in several locations. - x = float(self.convert_xunits(self._dashx)) - y = float(self.convert_yunits(self._dashy)) - return x, y - - def get_position(self): - "Return the position of the text as a tuple (*x*, *y*)" - # This should return the same data (possibly unitized) as was - # specified with set_x and set_y - return self._dashx, self._dashy - - def get_prop_tup(self, renderer=None): - """ - Return a hashable tuple of properties. - - Not intended to be human readable, but useful for backends who - want to cache derived information about text (e.g., layouts) and - need to know if the text has changed. - """ - return (*Text.get_prop_tup(self, renderer=renderer), - self._x, self._y, self._dashlength, self._dashdirection, - self._dashrotation, self._dashpad, self._dashpush) - - def draw(self, renderer): - """ - Draw the :class:`TextWithDash` object to the given *renderer*. - """ - self.update_coords(renderer) - Text.draw(self, renderer) - if self.get_dashlength() > 0.0: - self.dashline.draw(renderer) - self.stale = False - - def update_coords(self, renderer): - """ - Computes the actual *x*, *y* coordinates for text based on the - input *x*, *y* and the *dashlength*. Since the rotation is - with respect to the actual canvas's coordinates we need to map - back and forth. - """ - dashx, dashy = self.get_unitless_position() - dashlength = self.get_dashlength() - # Shortcircuit this process if we don't have a dash - if dashlength == 0.0: - self._x, self._y = dashx, dashy - return - - dashrotation = self.get_dashrotation() - dashdirection = self.get_dashdirection() - dashpad = self.get_dashpad() - dashpush = self.get_dashpush() - - angle = get_rotation(dashrotation) - theta = np.pi * (angle / 180.0 + dashdirection - 1) - cos_theta, sin_theta = np.cos(theta), np.sin(theta) - - transform = self.get_transform() - - # Compute the dash end points - # The 'c' prefix is for canvas coordinates - cxy = transform.transform((dashx, dashy)) - cd = np.array([cos_theta, sin_theta]) - c1 = cxy + dashpush * cd - c2 = cxy + (dashpush + dashlength) * cd - - inverse = transform.inverted() - (x1, y1), (x2, y2) = inverse.transform([c1, c2]) - self.dashline.set_data((x1, x2), (y1, y2)) - - # We now need to extend this vector out to - # the center of the text area. - # The basic problem here is that we're "rotating" - # two separate objects but want it to appear as - # if they're rotated together. - # This is made non-trivial because of the - # interaction between text rotation and alignment - - # text alignment is based on the bbox after rotation. - # We reset/force both alignments to 'center' - # so we can do something relatively reasonable. - # There's probably a better way to do this by - # embedding all this in the object's transformations, - # but I don't grok the transformation stuff - # well enough yet. - we = Text.get_window_extent(self, renderer=renderer) - w, h = we.width, we.height - # Watch for zeros - if sin_theta == 0.0: - dx = w - dy = 0.0 - elif cos_theta == 0.0: - dx = 0.0 - dy = h - else: - tan_theta = sin_theta / cos_theta - dx = w - dy = w * tan_theta - if dy > h or dy < -h: - dy = h - dx = h / tan_theta - cwd = np.array([dx, dy]) / 2 - cwd *= 1 + dashpad / np.sqrt(np.dot(cwd, cwd)) - cw = c2 + (dashdirection * 2 - 1) * cwd - - self._x, self._y = inverse.transform(cw) - - # Now set the window extent - # I'm not at all sure this is the right way to do this. - we = Text.get_window_extent(self, renderer=renderer) - self._twd_window_extent = we.frozen() - self._twd_window_extent.update_from_data_xy(np.array([c1]), False) - - # Finally, make text align center - Text.set_horizontalalignment(self, 'center') - Text.set_verticalalignment(self, 'center') - - def get_window_extent(self, renderer=None): - ''' - Return a :class:`~matplotlib.transforms.Bbox` object bounding - the text, in display units. - - In addition to being used internally, this is useful for - specifying clickable regions in a png file on a web page. - - *renderer* defaults to the _renderer attribute of the text - object. This is not assigned until the first execution of - :meth:`draw`, so you must use this kwarg if you want - to call :meth:`get_window_extent` prior to the first - :meth:`draw`. For getting web page regions, it is - simpler to call the method after saving the figure. - ''' - self.update_coords(renderer) - if self.get_dashlength() == 0.0: - return Text.get_window_extent(self, renderer=renderer) - else: - return self._twd_window_extent - - def get_dashlength(self): - """ - Get the length of the dash. - """ - return self._dashlength - - def set_dashlength(self, dl): - """ - Set the length of the dash, in canvas units. - - Parameters - ---------- - dl : float - """ - self._dashlength = dl - self.stale = True - - def get_dashdirection(self): - """ - Get the direction dash. 1 is before the text and 0 is after. - """ - return self._dashdirection - - def set_dashdirection(self, dd): - """ - Set the direction of the dash following the text. 1 is before the text - and 0 is after. The default is 0, which is what you'd want for the - typical case of ticks below and on the left of the figure. - - Parameters - ---------- - dd : int (1 is before, 0 is after) - """ - self._dashdirection = dd - self.stale = True - - def get_dashrotation(self): - """ - Get the rotation of the dash in degrees. - """ - if self._dashrotation is None: - return self.get_rotation() - else: - return self._dashrotation - - def set_dashrotation(self, dr): - """ - Set the rotation of the dash, in degrees. - - Parameters - ---------- - dr : float - """ - self._dashrotation = dr - self.stale = True - - def get_dashpad(self): - """ - Get the extra spacing between the dash and the text, in canvas units. - """ - return self._dashpad - - def set_dashpad(self, dp): - """ - Set the "pad" of the TextWithDash, which is the extra spacing - between the dash and the text, in canvas units. - - Parameters - ---------- - dp : float - """ - self._dashpad = dp - self.stale = True - - def get_dashpush(self): - """ - Get the extra spacing between the dash and the specified text - position, in canvas units. - """ - return self._dashpush - - def set_dashpush(self, dp): - """ - Set the "push" of the TextWithDash, which is the extra spacing between - the beginning of the dash and the specified position. - - Parameters - ---------- - dp : float - """ - self._dashpush = dp - self.stale = True - - def set_position(self, xy): - """ - Set the (*x*, *y*) position of the :class:`TextWithDash`. - - Parameters - ---------- - xy : (float, float) - """ - self.set_x(xy[0]) - self.set_y(xy[1]) - - def set_x(self, x): - """ - Set the *x* position of the :class:`TextWithDash`. - - Parameters - ---------- - x : float - """ - self._dashx = float(x) - self.stale = True - - def set_y(self, y): - """ - Set the *y* position of the :class:`TextWithDash`. - - Parameters - ---------- - y : float - """ - self._dashy = float(y) - self.stale = True - - def set_transform(self, t): - """ - Set the :class:`matplotlib.transforms.Transform` instance used - by this artist. - - Parameters - ---------- - t : `~matplotlib.transforms.Transform` - """ - Text.set_transform(self, t) - self.dashline.set_transform(t) - self.stale = True - - def get_figure(self): - """Return the figure instance the artist belongs to.""" - return self.figure - - def set_figure(self, fig): - """ - Set the figure instance the artist belongs to. - - Parameters - ---------- - fig : `~matplotlib.figure.Figure` - """ - Text.set_figure(self, fig) - self.dashline.set_figure(fig) - -docstring.interpd.update(TextWithDash=artist.kwdoc(TextWithDash)) - - class OffsetFrom: """Callable helper class for working with `Annotation`."""