Skip to content

Should constrained_layout be applied every draw? #11630

Closed
@jklymak

Description

@jklymak

Discussion

Right now fig, ax = plt.subplots(constrained_layout=True) will cause the axes resizing to be carried out every draw event; hence the axes get repositioned if the figure changes size, or if zoom is applied, or panning, etc.

Is this desirable?

plt.tight_layout() is only called once, and does not get activated at draw time.

Pros:

  • if the window is resized, the axes positions are recalculated. That means the padding and margins expand or contract as the window gets smaller or larger.
  • if we zoom, and the ticklabels get much longer (i.e. more decimal places), the axes get resized.

Cons:

  • under zoom the axes keep changing size. That can be distracting. It doesn't always work either because there is a strange interaction with zoom and clipping boxes for artists.
  • for a plot w/ lots of axes it makes zooming/panning less responsive.

Any opinions? For my usual workflow, I'm probably fine with just calling constrained layout on the original plot. Any zooming etc are done on working plots versus final presentation plots, and I hard code limits in after the exploration stage. But I get the feeling some people use a lot of GUI work before saving their plots.

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