From 6355271f37423de1062ec99bf0886036b6cc62d9 Mon Sep 17 00:00:00 2001 From: Daniel Hitchcock Date: Sun, 24 Sep 2023 19:21:37 -0400 Subject: [PATCH] Removal of deprecations for Contour fix pyi fix pyi --- doc/api/artist_api.rst | 2 +- .../next_api_changes/removals/26907-DCH.rst | 14 +++++++ lib/matplotlib/contour.py | 38 ------------------- lib/matplotlib/contour.pyi | 9 +---- 4 files changed, 16 insertions(+), 47 deletions(-) create mode 100644 doc/api/next_api_changes/removals/26907-DCH.rst diff --git a/doc/api/artist_api.rst b/doc/api/artist_api.rst index df7a6e8b1c04..0ca3fb364c41 100644 --- a/doc/api/artist_api.rst +++ b/doc/api/artist_api.rst @@ -11,7 +11,7 @@ Inheritance Diagrams ==================== -.. 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.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.contour.ContourSet matplotlib.contour.QuadContourSet matplotlib.figure.FigureBase matplotlib.figure.Figure matplotlib.figure.SubFigure 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.Annulus 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.StepPatch 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.projections.polar.RadialAxis matplotlib.projections.polar.RadialTick matplotlib.projections.polar.ThetaAxis matplotlib.projections.polar.ThetaTick matplotlib.quiver.Barbs matplotlib.quiver.Quiver matplotlib.quiver.QuiverKey matplotlib.spines.Spine matplotlib.table.Cell matplotlib.table.Table matplotlib.text.Annotation matplotlib.text.Text matplotlib.tri.TriContourSet +.. 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.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.ContourSet matplotlib.contour.QuadContourSet matplotlib.figure.FigureBase matplotlib.figure.Figure matplotlib.figure.SubFigure 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.Annulus 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.StepPatch 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.projections.polar.RadialAxis matplotlib.projections.polar.RadialTick matplotlib.projections.polar.ThetaAxis matplotlib.projections.polar.ThetaTick matplotlib.quiver.Barbs matplotlib.quiver.Quiver matplotlib.quiver.QuiverKey matplotlib.spines.Spine matplotlib.table.Cell matplotlib.table.Table matplotlib.text.Annotation matplotlib.text.Text matplotlib.tri.TriContourSet :parts: 1 :private-bases: diff --git a/doc/api/next_api_changes/removals/26907-DCH.rst b/doc/api/next_api_changes/removals/26907-DCH.rst new file mode 100644 index 000000000000..889743ba9cb0 --- /dev/null +++ b/doc/api/next_api_changes/removals/26907-DCH.rst @@ -0,0 +1,14 @@ +``contour.ClabelText`` and ``ContourLabeler.set_label_props`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +... are removed. + +Use ``Text(..., transform_rotates_text=True)`` as a replacement for +``contour.ClabelText(...)`` and ``text.set(text=text, color=color, +fontproperties=labeler.labelFontProps, clip_box=labeler.axes.bbox)`` as a +replacement for the ``ContourLabeler.set_label_props(label, text, color)``. + +``ContourLabeler`` attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The ``labelFontProps``, ``labelFontSizeList``, and ``labelTextsList`` +attributes of `.ContourLabeler` have been removed. Use the ``labelTexts`` +attribute and the font properties of the corresponding text objects instead. diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index dc5ed5d626bc..4104bebfceda 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -25,20 +25,6 @@ import matplotlib.transforms as mtransforms -@_api.deprecated("3.7", alternative="Text.set_transform_rotates_text") -class ClabelText(Text): - """ - Unlike the ordinary text, the get_rotation returns an updated - angle in the pixel coordinate assuming that the input rotation is - an angle in data coordinate (or whatever transform set). - """ - - def get_rotation(self): - new_angle, = self.get_transform().transform_angles( - [super().get_rotation()], [self.get_position()]) - return new_angle - - def _contour_labeler_event_handler(cs, inline, inline_spacing, event): canvas = cs.axes.figure.canvas is_button = event.name == "button_press_event" @@ -223,22 +209,6 @@ def clabel(self, levels=None, *, return cbook.silent_list('text.Text', self.labelTexts) - @_api.deprecated("3.7", alternative="cs.labelTexts[0].get_font()") - @property - def labelFontProps(self): - return self._label_font_props - - @_api.deprecated("3.7", alternative=( - "[cs.labelTexts[0].get_font().get_size()] * len(cs.labelLevelList)")) - @property - def labelFontSizeList(self): - return [self._label_font_props.get_size()] * len(self.labelLevelList) - - @_api.deprecated("3.7", alternative="cs.labelTexts") - @property - def labelTextsList(self): - return cbook.silent_list('text.Text', self.labelTexts) - def print_label(self, linecontour, labelwidth): """Return whether a contour is long enough to hold a label.""" return (len(linecontour) > 10 * labelwidth @@ -260,14 +230,6 @@ def _get_nth_label_width(self, nth): figure=fig, fontproperties=self._label_font_props) .get_window_extent(renderer).width) - @_api.deprecated("3.7", alternative="Artist.set") - def set_label_props(self, label, text, color): - """Set the label properties - color, fontsize, text.""" - label.set_text(text) - label.set_color(color) - label.set_fontproperties(self._label_font_props) - label.set_clip_box(self.axes.bbox) - def get_text(self, lev, fmt): """Get the text of the label.""" if isinstance(lev, str): diff --git a/lib/matplotlib/contour.pyi b/lib/matplotlib/contour.pyi index 4a1e1e1d9d2e..ca034c4af265 100644 --- a/lib/matplotlib/contour.pyi +++ b/lib/matplotlib/contour.pyi @@ -16,7 +16,7 @@ from collections.abc import Callable, Iterable, Sequence from typing import Literal from .typing import ColorType -class ClabelText(Text): ... + class ContourLabeler: labelFmt: str | Formatter | Callable[[float], str] | dict[float, str] @@ -41,15 +41,8 @@ class ContourLabeler: rightside_up: bool = ..., zorder: float | None = ... ) -> list[Text]: ... - @property - def labelFontProps(self) -> FontProperties: ... - @property - def labelFontSizeList(self) -> list[float]: ... - @property - def labelTextsList(self) -> list[Text]: ... def print_label(self, linecontour: ArrayLike, labelwidth: float) -> bool: ... def too_close(self, x: float, y: float, lw: float) -> bool: ... - def set_label_props(self, label: Text, text: str, color: ColorType) -> None: ... def get_text( self, lev: float,