Skip to content

regularize get_window_extent #4058

Closed
Closed

Description

@tacaswell

The call signature on get_window_extent is not uniform, we should probably fix this.

tcaswell@eowyn:lib$ ack-grep 'def get_window_extent'
mpl_toolkits/axisartist/axis_artist.py
437:    def get_window_extent(self, renderer):
625:    def get_window_extent(self, renderer):
806:    def get_window_extents(self, renderer):

matplotlib/axes/_base.py
473:    def get_window_extent(self, *args, **kwargs):

matplotlib/artist.py
190:    def get_window_extent(self, renderer):

matplotlib/lines.py
531:    def get_window_extent(self, renderer):

matplotlib/image.py
1097:    def get_window_extent(self, renderer=None):

matplotlib/text.py
763:    def get_window_extent(self, renderer=None, dpi=None):
1285:    def get_window_extent(self, renderer=None):
2088:    def get_window_extent(self, renderer=None):

matplotlib/figure.py
490:    def get_window_extent(self, *args, **kwargs):

matplotlib/offsetbox.py
252:    def get_window_extent(self, renderer):
618:    def get_window_extent(self, renderer):
769:    def get_window_extent(self, renderer):
884:    def get_window_extent(self, renderer):
1058:    def get_window_extent(self, renderer):
1265:    def get_window_extent(self, renderer):

matplotlib/patches.py
490:    def get_window_extent(self, renderer=None):

matplotlib/legend.py
798:    def get_window_extent(self, *args, **kwargs):

matplotlib/table.py
288:    def get_window_extent(self, renderer):

matplotlib/collections.py
207:    def get_window_extent(self, renderer):

  • for Axes and Figure the arguments are ignored, in legend they are passed through to Patch's . These should probably be given explicit arguments.
  • Text effectively implements a context manager on the figure.dpi. From the doc-string this seems like it is for making image maps for web images easy, but there has to be a better way to do this.
  • if we are going to let artists cache the renderer, it should happen at the artist level, not on a per-subclass basis

Activity

  1. added
    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …
    API: changesChanges to the public API, typically requiring deprecation.
    on Jan 31, 2015
  2. added this to the milestone on Jan 31, 2015
  3. modified the milestones: , on Mar 21, 2016
  4. modified the milestones: , on Oct 3, 2017
  5. oscargus commented on Mar 9, 2023

    @oscargus
    Member

    This seems to be solved now:

    lib/matplotlib/artist.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/axes/_base.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/collections.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/colorbar.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/figure.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/image.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/image.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/legend.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/lines.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/offsetbox.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/offsetbox.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/patches.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/spines.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/table.py:    def get_window_extent(self, renderer=None):
    lib/matplotlib/text.py:    def get_window_extent(self, renderer=None, dpi=None):
    lib/matplotlib/text.py:    def get_window_extent(self, renderer=None):
    lib/mpl_toolkits/axisartist/axis_artist.py:    def get_window_extent(self, renderer=None):
    lib/mpl_toolkits/axisartist/axis_artist.py:    def get_window_extent(self, renderer=None):
    lib/mpl_toolkits/axisartist/axis_artist.py:    def get_window_extents(self, renderer=None):
    lib/mpl_toolkits/axisartist/axisline_style.py:        def get_window_extent(self, renderer=None):
    
  6. QuLogic commented on Mar 9, 2023

    @QuLogic
    Member

    I believe it was #22745 that did this.

  7. modified the milestones: future releases, v3.6.0 on Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: changesChanges to the public API, typically requiring deprecation.API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions