We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Bug summary
Might be a documentation issue. The constrainedlayout_guide says
constrained_layout needs to be activated before any axes are added to a figure. Two ways of doing so are using the respective argument to subplots() or figure(), [...]
constrained_layout needs to be activated before any axes are added to a figure. Two ways of doing so are
subplots()
figure()
However, fig = plt.figure(constrained_layout=True) does not seem to have any effect.
fig = plt.figure(constrained_layout=True)
Code for reproduction
import matplotlib.pyplot as plt def example_plot(ax, fontsize=12): ax.plot([1, 2]) ax.set_xlabel('x-label', fontsize=fontsize) ax.set_ylabel('y-label', fontsize=fontsize) ax.set_title('Title', fontsize=fontsize) fig = plt.figure(constrained_layout=True) ax1 = fig.add_subplot(211) ax2 = fig.add_subplot(212) for ax in [ax1, ax2]: example_plot(ax, fontsize=24) plt.show()
Actual outcome
Expected outcome
Matplotlib version
print(matplotlib.get_backend())
The text was updated successfully, but these errors were encountered:
Constrained layout doesn't work with add_subplot in the numeric form, only the gridspec form. i.e.
add_subplot
gridspec
fig = plt.figure(constrained_layout=True) gs = fig.add_gridspec(2, 1) ax1 = fig.add_subplot(gs[0]) ax2 = fig.add_subplot(gs[1])
works fine.
Probably the docs should be clearer about that. TBH I didn't realize add_subplot worked with the numeric arguments.
Sorry, something went wrong.
See #17347
Moved to 3.4 because I don't think this is time critical. OTOH if someone wanted to merge #17347 in time for 3.3 this would be a helpful addition
jklymak
Successfully merging a pull request may close this issue.
Bug report
Bug summary
Might be a documentation issue. The constrainedlayout_guide says
However,
fig = plt.figure(constrained_layout=True)
does not seem to have any effect.Code for reproduction
Actual outcome
Expected outcome
Matplotlib version
print(matplotlib.get_backend())
): Qt5AggThe text was updated successfully, but these errors were encountered: