diff --git a/doc/api/next_api_changes/behavior/25456-AL.rst b/doc/api/next_api_changes/behavior/25456-AL.rst new file mode 100644 index 000000000000..fc3080439c5e --- /dev/null +++ b/doc/api/next_api_changes/behavior/25456-AL.rst @@ -0,0 +1,10 @@ +Changes of API after deprecation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- `.dviread.find_tex_file` now raises `FileNotFoundError` when the requested filename is + not found. +- `.Figure.colorbar` now raises if *cax* is not given and it is unable to determine from + which Axes to steal space, i.e. if *ax* is also not given and *mappable* has not been + added to an Axes. +- `.pyplot.subplot` and `.pyplot.subplot2grid` no longer auto-remove preexisting + overlapping Axes; explicitly call ``Axes.remove`` as needed. diff --git a/doc/api/next_api_changes/removals/25456-AL.rst b/doc/api/next_api_changes/removals/25456-AL.rst new file mode 100644 index 000000000000..2d9011a504ce --- /dev/null +++ b/doc/api/next_api_changes/removals/25456-AL.rst @@ -0,0 +1,51 @@ +Removal of deprecated APIs +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following deprecated APIs have been removed. Unless a replacement is stated, please +vendor the previous implementation if needed. + +- The following methods of `.FigureCanvasBase`: ``pick`` (use ``Figure.pick`` instead), + ``resize``, ``draw_event``, ``resize_event``, ``close_event``, ``key_press_event``, + ``key_release_event``, ``pick_event``, ``scroll_event``, ``button_press_event``, + ``button_release_event``, ``motion_notify_event``, ``leave_notify_event``, + ``enter_notify_event`` (for all the ``foo_event`` methods, construct the relevant + `.Event` object and call ``canvas.callbacks.process(event.name, event)`` instead). +- ``ToolBase.destroy`` (connect to ``tool_removed_event`` instead). +- The *cleared* parameter to `.FigureCanvasAgg.get_renderer` (call ``renderer.clear()`` + instead). +- The following methods of `.RendererCairo`: ``set_ctx_from_surface`` and + ``set_width_height`` (use ``set_context`` instead, which automatically infers the + canvas size). +- The ``window`` or ``win`` parameters and/or attributes of ``NavigationToolbar2Tk``, + ``NavigationToolbar2GTK3``, and ``NavigationToolbar2GTK4``, and the ``lastrect`` + attribute of ``NavigationToolbar2Tk`` +- The ``error_msg_gtk`` function and the ``icon_filename`` and ``window_icon`` globals + in ``backend_gtk3``; the ``error_msg_wx`` function in ``backend_wx``. +- ``FigureManagerGTK3Agg`` and ``FigureManagerGTK4Agg`` (use ``FigureManagerGTK3`` + instead); ``RendererGTK3Cairo`` and ``RendererGTK4Cairo``. +- ``NavigationToolbar2Mac.prepare_configure_subplots`` (use + `~.NavigationToolbar2.configure_subplots` instead). +- ``FigureManagerMac.close``. +- The ``qApp`` global in `.backend_qt` (use ``QtWidgets.QApplication.instance()`` + instead). +- The ``offset_text_height`` method of ``RendererWx``; the ``sizer``, ``figmgr``, + ``num``, ``toolbar``, ``toolmanager``, ``get_canvas``, and ``get_figure_manager`` + attributes or methods of ``FigureFrameWx`` (use ``frame.GetSizer()``, + ``frame.canvas.manager``, ``frame.canvas.manager.num``, ``frame.GetToolBar()``, + ``frame.canvas.manager.toolmanager``, the *canvas_class* constructor parameter, and + ``frame.canvas.manager``, respectively, instead). +- ``FigureFrameWxAgg`` and ``FigureFrameWxCairo`` (use + ``FigureFrameWx(..., canvas_class=FigureCanvasWxAgg)`` and + ``FigureFrameWx(..., canvas_class=FigureCanvasWxCairo)``, respectively, instead). +- The ``filled`` attribute and the ``draw_all`` method of `.Colorbar` (instead of + ``draw_all``, use ``figure.draw_without_rendering``). +- Calling `.MarkerStyle` without setting the *marker* parameter or setting it to None + (use ``MarkerStyle("")`` instead). +- Support for third-party canvas classes without a ``required_interactive_framework`` + attribute (this can only occur if the canvas class does not inherit from + `.FigureCanvasBase`). +- The ``canvas`` and ``background`` attributes of `.MultiCursor`; the + ``state_modifier_keys`` attribute of selector widgets. +- Passing *useblit*, *horizOn*, or *vertOn* positionally to `.MultiCursor`. +- Support for the ``seaborn-`` styles; use ``seaborn-v0_8-`` instead, or + directly use the seaborn API. diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index a5118c51cfba..9200c1269a59 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1708,7 +1708,6 @@ def __init__(self, figure=None): self.widgetlock = widgets.LockDraw() self._button = None # the button pressed self._key = None # the key pressed - self._lastx, self._lasty = None, None self.mouse_grabber = None # the Axes currently grabbing mouse self.toolbar = None # NavigationToolbar2 will set me self._is_idle_drawing = False @@ -1779,241 +1778,9 @@ def is_saving(self): """ return self._is_saving - @_api.deprecated("3.6", alternative="canvas.figure.pick") - def pick(self, mouseevent): - if not self.widgetlock.locked(): - self.figure.pick(mouseevent) - def blit(self, bbox=None): """Blit the canvas in bbox (default entire canvas).""" - def resize(self, w, h): - """ - UNUSED: Set the canvas size in pixels. - - Certain backends may implement a similar method internally, but this is - not a requirement of, nor is it used by, Matplotlib itself. - """ - # The entire method is actually deprecated, but we allow pass-through - # to a parent class to support e.g. QWidget.resize. - if hasattr(super(), "resize"): - return super().resize(w, h) - else: - _api.warn_deprecated("3.6", name="resize", obj_type="method", - alternative="FigureManagerBase.resize") - - @_api.deprecated("3.6", alternative=( - "callbacks.process('draw_event', DrawEvent(...))")) - def draw_event(self, renderer): - """Pass a `DrawEvent` to all functions connected to ``draw_event``.""" - s = 'draw_event' - event = DrawEvent(s, self, renderer) - self.callbacks.process(s, event) - - @_api.deprecated("3.6", alternative=( - "callbacks.process('resize_event', ResizeEvent(...))")) - def resize_event(self): - """ - Pass a `ResizeEvent` to all functions connected to ``resize_event``. - """ - s = 'resize_event' - event = ResizeEvent(s, self) - self.callbacks.process(s, event) - self.draw_idle() - - @_api.deprecated("3.6", alternative=( - "callbacks.process('close_event', CloseEvent(...))")) - def close_event(self, guiEvent=None): - """ - Pass a `CloseEvent` to all functions connected to ``close_event``. - """ - s = 'close_event' - try: - event = CloseEvent(s, self, guiEvent=guiEvent) - self.callbacks.process(s, event) - except (TypeError, AttributeError): - pass - # Suppress the TypeError when the python session is being killed. - # It may be that a better solution would be a mechanism to - # disconnect all callbacks upon shutdown. - # AttributeError occurs on OSX with qt4agg upon exiting - # with an open window; 'callbacks' attribute no longer exists. - - @_api.deprecated("3.6", alternative=( - "callbacks.process('key_press_event', KeyEvent(...))")) - def key_press_event(self, key, guiEvent=None): - """ - Pass a `KeyEvent` to all functions connected to ``key_press_event``. - """ - self._key = key - s = 'key_press_event' - event = KeyEvent( - s, self, key, self._lastx, self._lasty, guiEvent=guiEvent) - self.callbacks.process(s, event) - - @_api.deprecated("3.6", alternative=( - "callbacks.process('key_release_event', KeyEvent(...))")) - def key_release_event(self, key, guiEvent=None): - """ - Pass a `KeyEvent` to all functions connected to ``key_release_event``. - """ - s = 'key_release_event' - event = KeyEvent( - s, self, key, self._lastx, self._lasty, guiEvent=guiEvent) - self.callbacks.process(s, event) - self._key = None - - @_api.deprecated("3.6", alternative=( - "callbacks.process('pick_event', PickEvent(...))")) - def pick_event(self, mouseevent, artist, **kwargs): - """ - Callback processing for pick events. - - This method will be called by artists who are picked and will - fire off `PickEvent` callbacks registered listeners. - - Note that artists are not pickable by default (see - `.Artist.set_picker`). - """ - s = 'pick_event' - event = PickEvent(s, self, mouseevent, artist, - guiEvent=mouseevent.guiEvent, - **kwargs) - self.callbacks.process(s, event) - - @_api.deprecated("3.6", alternative=( - "callbacks.process('scroll_event', MouseEvent(...))")) - def scroll_event(self, x, y, step, guiEvent=None): - """ - Callback processing for scroll events. - - Backend derived classes should call this function on any - scroll wheel event. (*x*, *y*) are the canvas coords ((0, 0) is lower - left). button and key are as defined in `MouseEvent`. - - This method will call all functions connected to the 'scroll_event' - with a `MouseEvent` instance. - """ - if step >= 0: - self._button = 'up' - else: - self._button = 'down' - s = 'scroll_event' - mouseevent = MouseEvent(s, self, x, y, self._button, self._key, - step=step, guiEvent=guiEvent) - self.callbacks.process(s, mouseevent) - - @_api.deprecated("3.6", alternative=( - "callbacks.process('button_press_event', MouseEvent(...))")) - def button_press_event(self, x, y, button, dblclick=False, guiEvent=None): - """ - Callback processing for mouse button press events. - - Backend derived classes should call this function on any mouse - button press. (*x*, *y*) are the canvas coords ((0, 0) is lower left). - button and key are as defined in `MouseEvent`. - - This method will call all functions connected to the - 'button_press_event' with a `MouseEvent` instance. - """ - self._button = button - s = 'button_press_event' - mouseevent = MouseEvent(s, self, x, y, button, self._key, - dblclick=dblclick, guiEvent=guiEvent) - self.callbacks.process(s, mouseevent) - - @_api.deprecated("3.6", alternative=( - "callbacks.process('button_release_event', MouseEvent(...))")) - def button_release_event(self, x, y, button, guiEvent=None): - """ - Callback processing for mouse button release events. - - Backend derived classes should call this function on any mouse - button release. - - This method will call all functions connected to the - 'button_release_event' with a `MouseEvent` instance. - - Parameters - ---------- - x : float - The canvas coordinates where 0=left. - y : float - The canvas coordinates where 0=bottom. - guiEvent - The native UI event that generated the Matplotlib event. - """ - s = 'button_release_event' - event = MouseEvent(s, self, x, y, button, self._key, guiEvent=guiEvent) - self.callbacks.process(s, event) - self._button = None - - # Also remove _lastx, _lasty when this goes away. - @_api.deprecated("3.6", alternative=( - "callbacks.process('motion_notify_event', MouseEvent(...))")) - def motion_notify_event(self, x, y, guiEvent=None): - """ - Callback processing for mouse movement events. - - Backend derived classes should call this function on any - motion-notify-event. - - This method will call all functions connected to the - 'motion_notify_event' with a `MouseEvent` instance. - - Parameters - ---------- - x : float - The canvas coordinates where 0=left. - y : float - The canvas coordinates where 0=bottom. - guiEvent - The native UI event that generated the Matplotlib event. - """ - self._lastx, self._lasty = x, y - s = 'motion_notify_event' - event = MouseEvent(s, self, x, y, self._button, self._key, - guiEvent=guiEvent) - self.callbacks.process(s, event) - - @_api.deprecated("3.6", alternative=( - "callbacks.process('leave_notify_event', LocationEvent(...))")) - def leave_notify_event(self, guiEvent=None): - """ - Callback processing for the mouse cursor leaving the canvas. - - Backend derived classes should call this function when leaving - canvas. - - Parameters - ---------- - guiEvent - The native UI event that generated the Matplotlib event. - """ - self.callbacks.process('figure_leave_event', LocationEvent._lastevent) - LocationEvent._lastevent = None - self._lastx, self._lasty = None, None - - @_api.deprecated("3.6", alternative=( - "callbacks.process('enter_notify_event', LocationEvent(...))")) - def enter_notify_event(self, guiEvent=None, *, xy): - """ - Callback processing for the mouse cursor entering the canvas. - - Backend derived classes should call this function when entering - canvas. - - Parameters - ---------- - guiEvent - The native UI event that generated the Matplotlib event. - xy : (float, float) - The coordinate location of the pointer when the canvas is entered. - """ - self._lastx, self._lasty = x, y = xy - event = LocationEvent('figure_enter_event', self, x, y, guiEvent) - self.callbacks.process('figure_enter_event', event) - def inaxes(self, xy): """ Return the topmost visible `~.axes.Axes` containing the point *xy*. diff --git a/lib/matplotlib/backend_managers.py b/lib/matplotlib/backend_managers.py index ac74ff97a4e8..76f15030bcc5 100644 --- a/lib/matplotlib/backend_managers.py +++ b/lib/matplotlib/backend_managers.py @@ -204,23 +204,12 @@ def remove_tool(self, name): name : str Name of the tool. """ - tool = self.get_tool(name) - destroy = _api.deprecate_method_override( - backend_tools.ToolBase.destroy, tool, since="3.6", - alternative="tool_removed_event") - if destroy is not None: - destroy() - - # If it's a toggle tool and toggled, untoggle - if getattr(tool, 'toggled', False): + if getattr(tool, 'toggled', False): # If it's a toggled toggle tool, untoggle self.trigger_tool(tool, 'toolmanager') - self._remove_keys(name) - event = ToolEvent('tool_removed_event', self, tool) self._callbacks.process(event.name, event) - del self._tools[name] def add_tool(self, name, tool, *args, **kwargs): diff --git a/lib/matplotlib/backend_tools.py b/lib/matplotlib/backend_tools.py index 73425f915093..a1b1bf606c08 100644 --- a/lib/matplotlib/backend_tools.py +++ b/lib/matplotlib/backend_tools.py @@ -155,15 +155,6 @@ def trigger(self, sender, event, data=None): """ pass - @_api.deprecated("3.6", alternative="tool_removed_event") - def destroy(self): - """ - Destroy the tool. - - This method is called by `.ToolManager.remove_tool`. - """ - pass - class ToolToggleBase(ToolBase): """ diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index 121744a9913a..ac31ba1e387b 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -598,9 +598,6 @@ def full_screen_toggle(self): class NavigationToolbar2Tk(NavigationToolbar2, tk.Frame): - window = _api.deprecated("3.6", alternative="self.master")( - property(lambda self: self.master)) - def __init__(self, canvas, window=None, *, pack_toolbar=True): """ Parameters @@ -727,9 +724,6 @@ def remove_rubberband(self): self.canvas._tkcanvas.delete(self.canvas._rubberband_rect_black) self.canvas._rubberband_rect_black = None - lastrect = _api.deprecated("3.6")( - property(lambda self: self.canvas._rubberband_rect_black)) - def _set_image_for_button(self, button): """ Set the image for a button based on its pixel size. @@ -966,9 +960,6 @@ def remove_rubberband(self): NavigationToolbar2Tk.remove_rubberband( self._make_classic_style_pseudo_toolbar()) - lastrect = _api.deprecated("3.6")( - property(lambda self: self.figure.canvas._rubberband_rect_black)) - class ToolbarTk(ToolContainerBase, tk.Frame): def __init__(self, toolmanager, window=None): diff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py index 3d7dfa57a82e..34ba5f789d8e 100644 --- a/lib/matplotlib/backends/backend_agg.py +++ b/lib/matplotlib/backends/backend_agg.py @@ -403,16 +403,13 @@ def draw(self): # don't forget to call the superclass. super().draw() - @_api.delete_parameter("3.6", "cleared", alternative="renderer.clear()") - def get_renderer(self, cleared=False): + def get_renderer(self): w, h = self.figure.bbox.size key = w, h, self.figure.dpi reuse_renderer = (self._lastKey == key) if not reuse_renderer: self.renderer = RendererAgg(w, h, self.figure.dpi) self._lastKey = key - elif cleared: - self.renderer.clear() return self.renderer @_api.deprecated("3.8") diff --git a/lib/matplotlib/backends/backend_cairo.py b/lib/matplotlib/backends/backend_cairo.py index 9172fa40684d..db869fdd1eac 100644 --- a/lib/matplotlib/backends/backend_cairo.py +++ b/lib/matplotlib/backends/backend_cairo.py @@ -100,15 +100,6 @@ def set_context(self, ctx): self.gc.ctx = ctx self.width, self.height = size - @_api.deprecated("3.6", alternative="set_context") - def set_ctx_from_surface(self, surface): - self.gc.ctx = cairo.Context(surface) - - @_api.deprecated("3.6") - def set_width_height(self, width, height): - self.width = width - self.height = height - def _fill_and_stroke(self, ctx, fill_c, alpha, alpha_overrides): if fill_c is not None: ctx.save() @@ -501,19 +492,6 @@ def _save(self, fmt, fobj, *, orientation='portrait'): print_svgz = functools.partialmethod(_save, "svgz") -@_api.deprecated("3.6") -class _RendererGTKCairo(RendererCairo): - def set_context(self, ctx): - if (cairo.__name__ == "cairocffi" - and not isinstance(ctx, cairo.Context)): - ctx = cairo.Context._from_pointer( - cairo.ffi.cast( - 'cairo_t **', - id(ctx) + object.__basicsize__)[0], - incref=True) - self.gc.ctx = ctx - - @_Backend.export class _BackendCairo(_Backend): backend_version = cairo.version diff --git a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py index b4cf76812a18..03b4175fd7ec 100644 --- a/lib/matplotlib/backends/backend_gtk3.py +++ b/lib/matplotlib/backends/backend_gtk3.py @@ -2,7 +2,6 @@ import logging import os from pathlib import Path -import sys import matplotlib as mpl from matplotlib import _api, backend_tools, cbook @@ -35,16 +34,6 @@ _log = logging.getLogger(__name__) -@_api.caching_module_getattr # module-level deprecations -class __getattr__: - icon_filename = _api.deprecated("3.6", obj_type="")(property( - lambda self: - "matplotlib.png" if sys.platform == "win32" else "matplotlib.svg")) - window_icon = _api.deprecated("3.6", obj_type="")(property( - lambda self: - str(cbook._get_data_path("images", __getattr__("icon_filename"))))) - - @functools.cache def _mpl_to_gtk_cursor(mpl_cursor): return Gdk.Cursor.new_from_name( @@ -299,9 +288,7 @@ def flush_events(self): class NavigationToolbar2GTK3(_NavigationToolbar2GTK, Gtk.Toolbar): - @_api.delete_parameter("3.6", "window") - def __init__(self, canvas, window=None): - self._win = window + def __init__(self, canvas): GObject.GObject.__init__(self) self.set_style(Gtk.ToolbarStyle.ICONS) @@ -349,8 +336,6 @@ def __init__(self, canvas, window=None): _NavigationToolbar2GTK.__init__(self, canvas) - win = _api.deprecated("3.6")(property(lambda self: self._win)) - def save_figure(self, *args): dialog = Gtk.FileChooserDialog( title="Save the figure", @@ -584,21 +569,6 @@ def trigger(self, *args, **kwargs): clipboard.set_image(pb) -@_api.deprecated("3.6") -def error_msg_gtk(msg, parent=None): - if parent is not None: # find the toplevel Gtk.Window - parent = parent.get_toplevel() - if not parent.is_toplevel(): - parent = None - if not isinstance(msg, str): - msg = ','.join(map(str, msg)) - dialog = Gtk.MessageDialog( - parent=parent, type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK, - message_format=msg) - dialog.run() - dialog.destroy() - - Toolbar = ToolbarGTK3 backend_tools._register_tool_class( FigureCanvasGTK3, _backend_gtk.ConfigureSubplotsGTK) diff --git a/lib/matplotlib/backends/backend_gtk3agg.py b/lib/matplotlib/backends/backend_gtk3agg.py index 10aa15ac2a6b..a006a4c6f127 100644 --- a/lib/matplotlib/backends/backend_gtk3agg.py +++ b/lib/matplotlib/backends/backend_gtk3agg.py @@ -1,6 +1,6 @@ import numpy as np -from .. import _api, cbook, transforms +from .. import cbook, transforms from . import backend_agg, backend_gtk3 from .backend_gtk3 import Gtk, _BackendGTK3 @@ -64,11 +64,6 @@ def blit(self, bbox=None): self.queue_draw_area(x, y, width, height) -@_api.deprecated("3.6", alternative="backend_gtk3.FigureManagerGTK3") -class FigureManagerGTK3Agg(backend_gtk3.FigureManagerGTK3): - pass - - @_BackendGTK3.export class _BackendGTK3Cairo(_BackendGTK3): FigureCanvas = FigureCanvasGTK3Agg diff --git a/lib/matplotlib/backends/backend_gtk3cairo.py b/lib/matplotlib/backends/backend_gtk3cairo.py index 49215510c178..1da8419e5381 100644 --- a/lib/matplotlib/backends/backend_gtk3cairo.py +++ b/lib/matplotlib/backends/backend_gtk3cairo.py @@ -1,7 +1,6 @@ from contextlib import nullcontext -from .backend_cairo import ( # noqa - FigureCanvasCairo, _RendererGTKCairo as RendererGTK3Cairo) +from .backend_cairo import FigureCanvasCairo from .backend_gtk3 import Gtk, FigureCanvasGTK3, _BackendGTK3 diff --git a/lib/matplotlib/backends/backend_gtk4.py b/lib/matplotlib/backends/backend_gtk4.py index 328819292018..1bdc137b9044 100644 --- a/lib/matplotlib/backends/backend_gtk4.py +++ b/lib/matplotlib/backends/backend_gtk4.py @@ -288,9 +288,7 @@ def flush_events(self): class NavigationToolbar2GTK4(_NavigationToolbar2GTK, Gtk.Box): - @_api.delete_parameter("3.6", "window") - def __init__(self, canvas, window=None): - self._win = window + def __init__(self, canvas): Gtk.Box.__init__(self) self.add_css_class('toolbar') @@ -332,8 +330,6 @@ def __init__(self, canvas, window=None): _NavigationToolbar2GTK.__init__(self, canvas) - win = _api.deprecated("3.6")(property(lambda self: self._win)) - def save_figure(self, *args): dialog = Gtk.FileChooserNative( title='Save the figure', diff --git a/lib/matplotlib/backends/backend_gtk4agg.py b/lib/matplotlib/backends/backend_gtk4agg.py index d7ee04616e72..efddfec56075 100644 --- a/lib/matplotlib/backends/backend_gtk4agg.py +++ b/lib/matplotlib/backends/backend_gtk4agg.py @@ -1,6 +1,6 @@ import numpy as np -from .. import _api, cbook +from .. import cbook from . import backend_agg, backend_gtk4 from .backend_gtk4 import Gtk, _BackendGTK4 @@ -31,11 +31,6 @@ def on_draw_event(self, widget, ctx): return False -@_api.deprecated("3.6", alternative="backend_gtk4.FigureManagerGTK4") -class FigureManagerGTK4Agg(backend_gtk4.FigureManagerGTK4): - pass - - @_BackendGTK4.export class _BackendGTK4Agg(_BackendGTK4): FigureCanvas = FigureCanvasGTK4Agg diff --git a/lib/matplotlib/backends/backend_gtk4cairo.py b/lib/matplotlib/backends/backend_gtk4cairo.py index 83cbd081c26d..d57f53fb28d6 100644 --- a/lib/matplotlib/backends/backend_gtk4cairo.py +++ b/lib/matplotlib/backends/backend_gtk4cairo.py @@ -1,7 +1,6 @@ from contextlib import nullcontext -from .backend_cairo import ( # noqa - FigureCanvasCairo, _RendererGTKCairo as RendererGTK4Cairo) +from .backend_cairo import FigureCanvasCairo from .backend_gtk4 import Gtk, FigureCanvasGTK4, _BackendGTK4 diff --git a/lib/matplotlib/backends/backend_macosx.py b/lib/matplotlib/backends/backend_macosx.py index 2867c13f430b..e914ea7ae7f6 100644 --- a/lib/matplotlib/backends/backend_macosx.py +++ b/lib/matplotlib/backends/backend_macosx.py @@ -8,8 +8,6 @@ from matplotlib.backend_bases import ( _Backend, FigureCanvasBase, FigureManagerBase, NavigationToolbar2, ResizeEvent, TimerBase) -from matplotlib.figure import Figure -from matplotlib.widgets import SubplotTool class TimerMac(_macosx.Timer, TimerBase): @@ -132,15 +130,6 @@ def save_figure(self, *args): mpl.rcParams['savefig.directory'] = os.path.dirname(filename) self.canvas.figure.savefig(filename) - @_api.deprecated("3.6", alternative='configure_subplots()') - def prepare_configure_subplots(self): - toolfig = Figure(figsize=(6, 3)) - canvas = FigureCanvasMac(toolfig) - toolfig.subplots_adjust(top=0.9) - # Need to keep a reference to the tool. - _tool = SubplotTool(self.canvas.figure, toolfig) - return canvas - class FigureManagerMac(_macosx.FigureManager, FigureManagerBase): _toolbar2_class = NavigationToolbar2Mac @@ -161,10 +150,6 @@ def _close_button_pressed(self): Gcf.destroy(self) self.canvas.flush_events() - @_api.deprecated("3.6") - def close(self): - return self._close_button_pressed() - @classmethod def start_main_loop(cls): _macosx.show() diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py index 1152db67b373..74fae0e3aef6 100644 --- a/lib/matplotlib/backends/backend_pdf.py +++ b/lib/matplotlib/backends/backend_pdf.py @@ -933,7 +933,7 @@ def dviFontName(self, dvifont): if dvi_info is not None: return dvi_info.pdfname - tex_font_map = dviread.PsfontsMap(dviread._find_tex_file('pdftex.map')) + tex_font_map = dviread.PsfontsMap(dviread.find_tex_file('pdftex.map')) psfont = tex_font_map[dvifont.texname] if psfont.filename is None: raise ValueError( diff --git a/lib/matplotlib/backends/backend_qt.py b/lib/matplotlib/backends/backend_qt.py index 8abc7db3b5fa..47cdca168013 100644 --- a/lib/matplotlib/backends/backend_qt.py +++ b/lib/matplotlib/backends/backend_qt.py @@ -88,13 +88,6 @@ } -@_api.caching_module_getattr -class __getattr__: - qApp = _api.deprecated( - "3.6", alternative="QtWidgets.QApplication.instance()")( - property(lambda self: QtWidgets.QApplication.instance())) - - # lru_cache keeps a reference to the QApplication instance, keeping it from # being GC'd. @functools.lru_cache(1) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 3236e713587b..01f109cda890 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -39,18 +39,6 @@ PIXELS_PER_INCH = 75 -@_api.deprecated("3.6") -def error_msg_wx(msg, parent=None): - """Signal an error condition with a popup error dialog.""" - dialog = wx.MessageDialog(parent=parent, - message=msg, - caption='Matplotlib backend_wx error', - style=wx.OK | wx.CENTRE) - dialog.ShowModal() - dialog.Destroy() - return None - - # lru_cache holds a reference to the App and prevents it from being gc'ed. @functools.lru_cache(1) def _create_wxapp(): @@ -150,10 +138,6 @@ def flipy(self): # docstring inherited return True - @_api.deprecated("3.6") - def offset_text_height(self): - return True - def get_text_width_height_descent(self, s, prop, ismath): # docstring inherited @@ -931,28 +915,6 @@ def __init__(self, num, fig, *, canvas_class): self.Bind(wx.EVT_CLOSE, self._on_close) - sizer = _api.deprecated("3.6", alternative="frame.GetSizer()")( - property(lambda self: self.GetSizer())) - figmgr = _api.deprecated("3.6", alternative="frame.canvas.manager")( - property(lambda self: self.canvas.manager)) - num = _api.deprecated("3.6", alternative="frame.canvas.manager.num")( - property(lambda self: self.canvas.manager.num)) - toolbar = _api.deprecated("3.6", alternative="frame.GetToolBar()")( - property(lambda self: self.GetToolBar())) - toolmanager = _api.deprecated( - "3.6", alternative="frame.canvas.manager.toolmanager")( - property(lambda self: self.canvas.manager.toolmanager)) - - @_api.deprecated( - "3.6", alternative="the canvas_class constructor parameter") - def get_canvas(self, fig): - return FigureCanvasWx(self, -1, fig) - - @_api.deprecated("3.6", alternative="frame.canvas.manager") - def get_figure_manager(self): - _log.debug("%s - get_figure_manager()", type(self)) - return self.canvas.manager - def _on_close(self, event): _log.debug("%s - on_close()", type(self)) CloseEvent("close_event", self.canvas)._process() diff --git a/lib/matplotlib/backends/backend_wxagg.py b/lib/matplotlib/backends/backend_wxagg.py index e92a4f81b19d..a5a9de07153d 100644 --- a/lib/matplotlib/backends/backend_wxagg.py +++ b/lib/matplotlib/backends/backend_wxagg.py @@ -1,19 +1,11 @@ import wx -from .. import _api from .backend_agg import FigureCanvasAgg -from .backend_wx import _BackendWx, _FigureCanvasWxBase, FigureFrameWx +from .backend_wx import _BackendWx, _FigureCanvasWxBase from .backend_wx import ( # noqa: F401 # pylint: disable=W0611 NavigationToolbar2Wx as NavigationToolbar2WxAgg) -@_api.deprecated( - "3.6", alternative="FigureFrameWx(..., canvas_class=FigureCanvasWxAgg)") -class FigureFrameWxAgg(FigureFrameWx): - def get_canvas(self, fig): - return FigureCanvasWxAgg(self, -1, fig) - - class FigureCanvasWxAgg(FigureCanvasAgg, _FigureCanvasWxBase): def draw(self, drawDC=None): """ diff --git a/lib/matplotlib/backends/backend_wxcairo.py b/lib/matplotlib/backends/backend_wxcairo.py index 5af9c195f392..c53e6af4b873 100644 --- a/lib/matplotlib/backends/backend_wxcairo.py +++ b/lib/matplotlib/backends/backend_wxcairo.py @@ -1,19 +1,11 @@ import wx.lib.wxcairo as wxcairo -from .. import _api from .backend_cairo import cairo, FigureCanvasCairo -from .backend_wx import _BackendWx, _FigureCanvasWxBase, FigureFrameWx +from .backend_wx import _BackendWx, _FigureCanvasWxBase from .backend_wx import ( # noqa: F401 # pylint: disable=W0611 NavigationToolbar2Wx as NavigationToolbar2WxCairo) -@_api.deprecated( - "3.6", alternative="FigureFrameWx(..., canvas_class=FigureCanvasWxCairo)") -class FigureFrameWxCairo(FigureFrameWx): - def get_canvas(self, fig): - return FigureCanvasWxCairo(self, -1, fig) - - class FigureCanvasWxCairo(FigureCanvasCairo, _FigureCanvasWxBase): def draw(self, drawDC=None): size = self.figure.bbox.size.astype(int) diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index d3d53e3d98f8..513fcbf827c4 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -488,8 +488,6 @@ def _cbar_cla(self): del self.ax.cla self.ax.cla() - filled = _api.deprecate_privatize_attribute("3.6") - def update_normal(self, mappable): """ Update solid patches, lines, etc. @@ -518,14 +516,6 @@ def update_normal(self, mappable): self.add_lines(CS) self.stale = True - @_api.deprecated("3.6", alternative="fig.draw_without_rendering()") - def draw_all(self): - """ - Calculate any free parameters based on the current cmap and norm, - and do all the drawing. - """ - self._draw_all() - def _draw_all(self): """ Calculate any free parameters based on the current cmap and norm, diff --git a/lib/matplotlib/dviread.py b/lib/matplotlib/dviread.py index 2298f92065b9..853a314ba256 100644 --- a/lib/matplotlib/dviread.py +++ b/lib/matplotlib/dviread.py @@ -996,9 +996,9 @@ def _parse_and_cache_line(self, line): if basename is None: basename = tfmname if encodingfile is not None: - encodingfile = _find_tex_file(encodingfile) + encodingfile = find_tex_file(encodingfile) if fontfile is not None: - fontfile = _find_tex_file(fontfile) + fontfile = find_tex_file(fontfile) self._parsed[tfmname] = PsFont( texname=tfmname, psname=basename, effects=effects, encoding=encodingfile, filename=fontfile) @@ -1053,7 +1053,7 @@ def search(self, filename): @lru_cache -def _find_tex_file(filename): +def find_tex_file(filename): """ Find a file in the texmf tree using kpathsea_. @@ -1111,24 +1111,9 @@ def _find_tex_file(filename): f"{filename!r} in your texmf tree, but could not find it") -# After the deprecation period elapses, delete this shim and rename -# _find_tex_file to find_tex_file everywhere. -def find_tex_file(filename): - try: - return _find_tex_file(filename) - except FileNotFoundError as exc: - _api.warn_deprecated( - "3.6", message=f"{exc.args[0]}; in the future, this will raise a " - f"FileNotFoundError.") - return "" - - -find_tex_file.__doc__ = _find_tex_file.__doc__ - - @lru_cache def _fontfile(cls, suffix, texname): - return cls(_find_tex_file(texname + suffix)) + return cls(find_tex_file(texname + suffix)) _tfmfile = partial(_fontfile, Tfm, ".tfm") @@ -1144,7 +1129,7 @@ def _fontfile(cls, suffix, texname): parser.add_argument("dpi", nargs="?", type=float, default=None) args = parser.parse_args() with Dvi(args.filename, args.dpi) as dvi: - fontmap = PsfontsMap(_find_tex_file('pdftex.map')) + fontmap = PsfontsMap(find_tex_file('pdftex.map')) for page in dvi: print(f"=== new page === " f"(w: {page.width}, h: {page.height}, d: {page.descent})") diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 9d3f630ea1ac..2262c3305bf5 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1262,15 +1262,13 @@ def colorbar( not self.get_layout_engine().colorbar_gridspec): use_gridspec = False if cax is None: - current_ax = self.gca() if ax is None: - _api.warn_deprecated("3.6", message=( + raise ValueError( 'Unable to determine Axes to steal space for Colorbar. ' - 'Using gca(), but will raise in the future. ' 'Either provide the *cax* argument to use as the Axes for ' 'the Colorbar, provide the *ax* argument to steal space ' - 'from it, or add *mappable* to an Axes.')) - ax = current_ax + 'from it, or add *mappable* to an Axes.') + current_ax = self.gca() if (use_gridspec and isinstance(ax, mpl.axes._base._AxesBase) and ax.get_subplotspec()): diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index cf4634575f88..76a7c0d5af81 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -135,7 +135,6 @@ import copy from collections.abc import Sized -import inspect import numpy as np @@ -223,10 +222,8 @@ class MarkerStyle: fillstyles = ('full', 'left', 'right', 'bottom', 'top', 'none') _half_fillstyles = ('left', 'right', 'bottom', 'top') - _unset = object() # For deprecation of MarkerStyle(). - - def __init__(self, marker=_unset, fillstyle=None, - transform=None, capstyle=None, joinstyle=None): + def __init__(self, marker, + fillstyle=None, transform=None, capstyle=None, joinstyle=None): """ Parameters ---------- @@ -255,25 +252,8 @@ def __init__(self, marker=_unset, fillstyle=None, self._user_capstyle = capstyle self._user_joinstyle = joinstyle self._set_fillstyle(fillstyle) - # Remove _unset and signature rewriting after deprecation elapses. - if marker is self._unset: - marker = "" - _api.warn_deprecated( - "3.6", message="Calling MarkerStyle() with no parameters is " - "deprecated since %(since)s; support will be removed " - "%(removal)s. Use MarkerStyle('') to construct an empty " - "MarkerStyle.") - if marker is None: - marker = "" - _api.warn_deprecated( - "3.6", message="MarkerStyle(None) is deprecated since " - "%(since)s; support will be removed %(removal)s. Use " - "MarkerStyle('') to construct an empty MarkerStyle.") self._set_marker(marker) - __init__.__signature__ = inspect.signature( # Only for deprecation period. - lambda self, marker, fillstyle=None: None) - def _recache(self): if self._marker_function is None: return diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index a2668375c49d..60e0a91a5860 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -181,16 +181,6 @@ def findobj(o=None, match=None, include_self=True): return o.findobj(match, include_self=include_self) -def _get_required_interactive_framework(backend_mod): - if not hasattr(getattr(backend_mod, "FigureCanvas", None), - "required_interactive_framework"): - _api.warn_deprecated( - "3.6", name="Support for FigureCanvases without a " - "required_interactive_framework attribute") - return None - # Inline this once the deprecation elapses. - return backend_mod.FigureCanvas.required_interactive_framework - _backend_mod = None @@ -270,7 +260,7 @@ def switch_backend(newbackend): backend_mod = importlib.import_module( cbook._backend_module_name(newbackend)) - required_framework = _get_required_interactive_framework(backend_mod) + required_framework = backend_mod.FigureCanvas.required_interactive_framework if required_framework is not None: current_framework = cbook._get_running_interactive_framework() if (current_framework and required_framework @@ -357,7 +347,7 @@ def draw_if_interactive(): def _warn_if_gui_out_of_main_thread(): warn = False - if _get_required_interactive_framework(_get_backend_mod()): + if _get_backend_mod().FigureCanvas.required_interactive_framework: if hasattr(threading, 'get_native_id'): # This compares native thread ids because even if Python-level # Thread objects match, the underlying OS thread (which is what @@ -1322,32 +1312,19 @@ def subplot(*args, **kwargs): key = SubplotSpec._from_subplot_args(fig, args) for ax in fig.axes: - # if we found an Axes at the position sort out if we can re-use it - if ax.get_subplotspec() == key: - # if the user passed no kwargs, re-use - if kwargs == {}: - break - # if the axes class and kwargs are identical, reuse - elif ax._projection_init == fig._process_projection_requirements( - *args, **kwargs - ): - break + # If we found an Axes at the position, we can re-use it if the user passed no + # kwargs or if the axes class and kwargs are identical. + if (ax.get_subplotspec() == key + and (kwargs == {} + or (ax._projection_init + == fig._process_projection_requirements(*args, **kwargs)))): + break else: # we have exhausted the known Axes and none match, make a new one! ax = fig.add_subplot(*args, **kwargs) fig.sca(ax) - axes_to_delete = [other for other in fig.axes - if other != ax and ax.bbox.fully_overlaps(other.bbox)] - if axes_to_delete: - _api.warn_deprecated( - "3.6", message="Auto-removal of overlapping axes is deprecated " - "since %(since)s and will be removed %(removal)s; explicitly call " - "ax.remove() as needed.") - for ax_to_del in axes_to_delete: - delaxes(ax_to_del) - return ax @@ -1659,27 +1636,12 @@ def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs): gs = fig.add_gridspec(nrows, ncols) ax = fig.add_subplot(gs[row:row+rowspan, col:col+colspan]) """ - if fig is None: fig = gcf() - rows, cols = shape gs = GridSpec._check_gridspec_exists(fig, rows, cols) - subplotspec = gs.new_subplotspec(loc, rowspan=rowspan, colspan=colspan) - ax = fig.add_subplot(subplotspec, **kwargs) - - axes_to_delete = [other for other in fig.axes - if other != ax and ax.bbox.fully_overlaps(other.bbox)] - if axes_to_delete: - _api.warn_deprecated( - "3.6", message="Auto-removal of overlapping axes is deprecated " - "since %(since)s and will be removed %(removal)s; explicitly call " - "ax.remove() as needed.") - for ax_to_del in axes_to_delete: - delaxes(ax_to_del) - - return ax + return fig.add_subplot(subplotspec, **kwargs) def twinx(ax=None): diff --git a/lib/matplotlib/style/core.py b/lib/matplotlib/style/core.py index a56b5347ac37..7e9008c56165 100644 --- a/lib/matplotlib/style/core.py +++ b/lib/matplotlib/style/core.py @@ -44,32 +44,6 @@ 'toolbar', 'timezone', 'figure.max_open_warning', 'figure.raise_window', 'savefig.directory', 'tk.window_focus', 'docstring.hardcopy', 'date.epoch'} -_DEPRECATED_SEABORN_STYLES = { - s: s.replace("seaborn", "seaborn-v0_8") - for s in [ - "seaborn", - "seaborn-bright", - "seaborn-colorblind", - "seaborn-dark", - "seaborn-darkgrid", - "seaborn-dark-palette", - "seaborn-deep", - "seaborn-muted", - "seaborn-notebook", - "seaborn-paper", - "seaborn-pastel", - "seaborn-poster", - "seaborn-talk", - "seaborn-ticks", - "seaborn-white", - "seaborn-whitegrid", - ] -} -_DEPRECATED_SEABORN_MSG = ( - "The seaborn styles shipped by Matplotlib are deprecated since %(since)s, " - "as they no longer correspond to the styles shipped by seaborn. However, " - "they will remain available as 'seaborn-v0_8-