Skip to content

Calling fig.tight_layout() before using mplpub.tight_layout() messes up padding #3

@ixjlyons

Description

@ixjlyons

Basic example:

import mplpub
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

ax.plot([1, 2, 3], [1, 4, 9])
ax.set_xlabel('x')
ax.set_ylabel('y')

fig.set_size_inches(4, 2)

# un-comment to screw up mplpub.tight_layout:
# fig.tight_layout()

mplpub.tight_layout(ax)
fig.savefig('plot.png', facecolor='#aaaaaa')

Good version:

tight_layout_centered_good

Bad version (called after fig.tight_layout()):

tight_layout_centered

Might be a matplotlib issue. Issue is essentially calling tight_layout multiple times with different pad values makes the second adjustment inaccurate. May be resolved by using subplots_adjust directly as needed for #2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions