Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Doc]: get_figure may return a SubFigure #28170

Copy link
Copy link
Closed
@rcomer

Description

@rcomer
Issue body actions

Documentation Link

https://matplotlib.org/devdocs/api/_as_gen/matplotlib.artist.Artist.get_figure.html#matplotlib.artist.Artist.get_figure

Problem

I'm not sure whether this is a documentation issue or a bug. The docstring for get_figure states that it returns a Figure, which I think implies the parent figure. If our artist is on a subfigure, it will return that. Note that SubFigure does not inherit from Figure.

In [1]: import matplotlib.pyplot as plt

In [2]: fig = plt.figure()

In [3]: sfig = fig.subfigures()

In [4]: ax = sfig.subplots()

In [5]: ax.get_figure()
Out[5]: <matplotlib.figure.SubFigure at 0x7dc0ddf4a870>

Suggested improvement

Either

  • modify the docstring to clarify you might get the SubFigure (and point to how you can get the parent Figure if you want it)
    or
  • fix the method so it returns the parent Figure

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.