Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: warn if user is using constrained layout and use subplots_adjust #11588

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

Merged
merged 1 commit into from
Jul 7, 2018

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Jul 6, 2018

PR Summary

Mysterious things can happen if constrained_layout=True for a figure and the user then tries to call subplots_adjust or tight_layout. This PR emits a warning in that case, and turns constrained_layout off

import matplotlib.pyplot as plt

fig, ax = plt.subplots(constrained_layout=True)
fig.subplots_adjust(top=0.8)
ax.set_xlabel('Xlabel')
ax.set_title('Title')
plt.show()
/Users/jklymak/matplotlib/lib/matplotlib/figure.py:2097: UserWarning: This figure was using constrained_layout==True, but that is incompatible with subplots_adjust and or tight_layout: setting constrained_layout==False.
  warnings.warn("This figure was using constrained_layout==True, "

Thanks @afvincent @timhoffm on gitter: https://gitter.im/matplotlib/matplotlib?at=5b3f0b8881816669a434e201

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant

@NelleV
Copy link
Member

NelleV commented Jul 7, 2018

The failing test seemed unrelated and flaky. I've restarted travis, and if it passes, we're good to merge!
Thanks @jklymak !

@tacaswell tacaswell merged commit a623149 into matplotlib:master Jul 7, 2018
@lumberbot-app
Copy link

lumberbot-app bot commented Jul 7, 2018

There seem to be a conflict, please backport manually

@jklymak jklymak deleted the doc-warn-if-CL-plus-TL branch July 13, 2018 21:10
tacaswell added a commit to tacaswell/matplotlib that referenced this pull request Aug 4, 2018
DOC: warn if user is using constrained layout and uses subplots_adjust

Conflicts:
	lib/matplotlib/figure.py
           - signature on master has changed to explicit kwargs,
             conflict due to that change.
@tacaswell
Copy link
Member

backported to v2.2.x as 648a04e

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

Successfully merging this pull request may close these issues.

4 participants