Skip to content

Strange behaviour when saving with constrained_layout and set_aspect('equal') #11809

@ArchangeGabriel

Description

@ArchangeGabriel

Bug report

Bug summary

When saving a figure with equal aspect while using constrained_layout, the output changes when iterating saves. The issue is not present with tight_layout instead. It also seems that the figure must be close to both borders for that issue to arise.

Code for reproduction

import matplotlib.pyplot as plt
fig = plt.figure(figsize=(6.4,6.4),constrained_layout=True)
fig.set_constrained_layout_pads(w_pad=0, h_pad=0)
ax = fig.add_subplot(111)
ax.set_aspect('equal')
plt.savefig('test.pdf')
plt.savefig('test2.pdf')
plt.savefig('test3.pdf')
plt.savefig('test4.pdf')
plt.savefig('test5.pdf')

Actual outcome

test.pdf
test2.pdf
test3.pdf
test4.pdf
test5.pdf

All outputs differ excepted for 4 and 5. The number of iterations required to reach convergence depends on the actual content of the figure (in another test, only 3 were required).

Expected outcome

All outputs should be identical. And from the above series and my other test mentionned, I would say the first one is the correct one here, but maybe not necessarily in more complex cases apparently (I’m currently toying with resizing the figure when using aspect equal to remove white space around and I’m getting strange results, I will probably post about this on the ML soon).

Matplotlib version

  • Operating system: Arch Linux
  • Matplotlib version: 2.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions