Skip to content

constrained_layout and texts outside of the axes #19358

Open
@anntzer

Description

@anntzer

Bug report

Bug summary

Texts outside of the axes extents interact "interestingly" with constrained_layout.

Code for reproduction

ax = figure(constrained_layout=True).add_subplot(); ax.plot([0, 1]); ax.text(2, 2, "hello")
ax = figure(constrained_layout=True).add_subplot(); ax.plot([0, 1]); ax.text(4, 4, "hello")

Actual outcome

The first example gives
1
the second one
2
together with (only for the second one)

UserWarning: constrained_layout not applied because axes sizes collapsed to zero.  Try making figure larger or axes decorations smaller.

(You can also try to pan the axes and get interesting results in that way.)

Expected outcome

I'm not actually sure how I'd actually want constrained_layout to handle such cases, but the current state seems... shaky.

Matplotlib version

  • Operating system: linux
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): HEAD
  • Matplotlib backend (print(matplotlib.get_backend())): qt5agg
  • Python version: 39
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: geometry managerLayoutEngine, Constrained layout, Tight layout

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions