Skip to content

constrained_layout (sometimes) clips multiline title/xlabel/ylabel #13843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pharshalp opened this issue Apr 2, 2019 · 3 comments
Closed

constrained_layout (sometimes) clips multiline title/xlabel/ylabel #13843

pharshalp opened this issue Apr 2, 2019 · 3 comments

Comments

@pharshalp
Copy link
Contributor

pharshalp commented Apr 2, 2019

Bug report

Bug summary
When a plot title/label consists of multiple lines (with some mathematics elements that require more vertical space), constrained_layout seems to not work correctly.

Code for reproduction

import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(3, 3), constrained_layout=True)
ax.set_title('First line \n'+r'Second line $\frac{x}{y}$')
ax.set_ylabel('ylabel')
ax.set_xlabel('xlabel')
fig.savefig('constrained_layout_issue.png')

Actual outcome
constrained_layout_issue

For now, I am avoiding this issue by increasing h_pad with plt.rcParams['figure.constrained_layout.h_pad'] = 6/72. But this doesn't feel right (there is a lot more blank space left at the bottom of the plot).
constrained_layout_issue

Matplotlib version

  • Operating system: Mac OS
  • Matplotlib version: 3.0.3
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version: 3.7.3
  • Jupyter version (if applicable):
  • Other libraries:
@ImportanceOfBeingErnest
Copy link
Member

This is fixed by either #11502 or #11499. It will not occur in master anymore and hence not in 3.1 once it is released.

@jklymak
Copy link
Member

jklymak commented Apr 2, 2019

Can you try w master? Pretty sure this is fixed. Edit: Oops cross post

@pharshalp
Copy link
Contributor Author

Thanks! yep, can confirm that this is fixed in the 3.1 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants