Skip to content

useless deprecation warning figbox #19938

Closed

Description

@2sn

Bug report

can'r make sense of deprecation warning

Code for reproduction

ax=gca()
ax.figbox

Actual outcome

MatplotlibDeprecationWarning: 
The figbox attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use get_subplotspec().get_position(self.figure) instead.

Expected outcome

A useful suggestion. I could not make sense from the deprecation or the documentation on how this was supposed to be replaced. I have no idea what object self.figure refers to, or even in what module get_subplotspec lives.

Matplotlib version

  • Operating system: Fedora 33
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): 3.4.1
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.9.4
  • Jupyter version (if applicable): IPython 7.22.0
  • Other libraries:

pip

Activity

  1. jklymak commented on Apr 11, 2021

    @jklymak
    Member

    Please try ax.get_subplotspec().get_position(self.figure)? Out of curiosity, what do you need figbox for?

  2. dstansby commented on Apr 11, 2021

    @dstansby
    Member

    Should that be ax.get_subplotspec().get_position(ax.figure)? (note self > ax) If so I think the message could be clearer by using ax instead of self.

  3. added this to the v3.4.2 milestone on Apr 13, 2021
  4. 2sn commented on Apr 16, 2021

    @2sn
    Author

    yes, I can call

    ax.get_subplotspec().get_position(ax.figure)
    

    but unfortunately this does not give the same result as was returned by ax.figbox for at least a decade until matplotlib 3.4.x. Since version 3.4 figbox now also returns the same value as suggested as replacement in the message. Whoever changed this in 3.4 broke it. I will submit a separate regression.

    Example from 3.3.4

    (Pdb) p ax.figbox
    Bbox([[0.07234432444852941, 0.07502374387254904], [0.9598087086397059, 0.9739713541666667]])
    (Pdb) ax.get_subplotspec().get_position(ax.figure)
    Bbox([[0.125, 0.10999999999999999], [0.9, 0.88]])
    

    Example form 3.4.1

    (Pdb) p ax.figbox
    Bbox([[0.125, 0.10999999999999999], [0.9, 0.88]])
    (Pdb) ax.get_subplotspec().get_position(ax.figure)
    Bbox([[0.125, 0.10999999999999999], [0.9, 0.88]])
    
  5. dstansby commented on Apr 16, 2021

    @dstansby
    Member

    I have opened a PR to improve the messages; if you could open a separate issue for the difference in output between the two commands that would be helpful 👍

  6. 2sn commented on Apr 16, 2021

    @2sn
    Author

    related to #19982

  7. 2sn commented on Apr 16, 2021

    @2sn
    Author

    If you update the deprecation warning message in a PR, please suggest as deprecation warning to replace ax.figbox by BboxTransformFrom(ax.figure.bbox).transform_bbox(ax.bbox).

    My personal view, however, is that you should just retain the figbox in ax - why not?

  8. 2sn commented on Apr 16, 2021

    @2sn
    Author

    update from #19982 - maybe ax.get_position() will do.

  9. jklymak commented on Apr 16, 2021

    @jklymak
    Member

    If you want the position, in figure-normalized units, that is the way to get it. I didn't even know figbox existed before this thread. I'll close, but feel free to ask for a re-open if this doesn't help.

  10. tacaswell commented on May 15, 2021

    @tacaswell
    Member

    Did we actually fix the deprecation warning to point at the correct method?

  11. jklymak commented on May 15, 2021

    @jklymak
    Member

    I sorry I'd misunderstood.

  12. 2sn commented on May 16, 2021

    @2sn
    Author

    As of 3.4.2 I see no change relative to 3.4.0.

    What I would have proposed is two items:

    1. replace/revert what is in 3.4 now by back to the behavior of <3.4 (i.e., return ax.get_position())
    2. replace the deprecation warning to point the user to ax.get_position()
  13. modified the milestones: v3.4.2, v3.4.3 on Jul 8, 2021
  14. linked a pull request that will close this issueFIX: fix figbox deprecation #20609on Jul 10, 2021
  15. changed the title [-]unuseful deprecation warning figbox[/-] [+]useless deprecation warning figbox[/+] on Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions