FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

legend.get_window_extent() fails · Issue #21285 · matplotlib/matplotlib · GitHub

Repository navigation

legend.get_window_extent() fails #21285

Closed

Description

Bug summary

It seems a bug has crept in with points_to_pixels not available as a function called by get_window_extent

Code for reproduction

(Pdb) leg2 = plt.legend(loc='upper left', ncol=2, fontsize=8)
(Pdb) leg2.get_window_extent()
*** AttributeError: 'NoneType' object has no attribute 'points_to_pixels'
(Pdb) print(matplotlib.__version__)
3.4.2
(Pdb) print(matplotlib.get_backend())
MacOSX
(Pdb) import sys; print(sys.version_info)
sys.version_info(major=3, minor=9, micro=6, releaselevel='final', serial=0)
$ jupyter --version
jupyter core     : 4.7.1
jupyter-notebook : 6.4.0
qtconsole        : 5.1.1
ipython          : 7.25.0
ipykernel        : 6.0.1
jupyter client   : 6.1.12
jupyter lab      : not installed
nbconvert        : 6.1.0
ipywidgets       : 7.6.3
nbformat         : 5.1.3
traitlets        : 5.0.5

Actual outcome

Error, as above

Expected outcome

I expected to get coords

Operating system

MacOS 11.6

Matplotlib Version

3.4.2

Matplotlib Backend

MacOSX

Python version

3.9.6

Jupyter version

core 4.7.1; notebook 6.4.0

Other libraries

No response

Installation

conda

Conda channel

conda-forge

Activity

  1. jklymak commented on Oct 6, 2021

    Member

    get_window_extent has a renderer argument. Its optional for some methods and required by others. If it is set to None it uses the cached renderer, but that requires a draw to have been executed first. In this case you have no draw, so the call fails.

    I'm skeptical this ever worked. If so, can you tell us what version? Maybe the renderer cache has changed in some way.

    In the meantime, it is safest to call leg2.get_window_extent(fig.canvas.get_renderer()).

  2. added this to the v3.6.0 milestone on Dec 1, 2021
  3. modified the milestones: v3.6.0, v3.7.0 on Aug 24, 2022
  4. QuLogic commented on Jan 25, 2023

    Member

    I believe this was fixed by #22745.

  5. modified the milestones: v3.7.0, v3.6.0 on Jan 25, 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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL