-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
tight_layout + lots of subplots + long ylabels inverts yaxis #8062
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
Comments
Something like diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py
index 1f61d95e9..85f8a26d0 100644
--- a/lib/matplotlib/tight_layout.py
+++ b/lib/matplotlib/tight_layout.py
@@ -199,7 +199,8 @@ def auto_adjust_subplotpars(fig, renderer,
if rows > 1:
vspace = (max(sum(s) for s in vspaces[cols:-cols])
+ vpad_inches / fig_height_inch)
- v_axes = (1 - margin_top - margin_bottom - vspace * (rows - 1)) / rows
+ v_axes = max((1 - margin_top - margin_bottom - vspace * (rows - 1)) / rows,
+ 0.01)
kwargs["hspace"] = vspace / v_axes
return kwargs (and likewise for vspace) "fixes" the issue but the subplots are still tiny and squished (fundamentally there's just not enough space) so as @NelleV suggested an error may be better. (it's |
I've stumbled onto this when plotting a 3x7 gridded figure in A4 paper. Has this been pushed? |
@amyspark This happens if the title or the axes labels are too long. There is (and probably will be) no fix for this - mainly because there is no canonical action to take here; if the elements in the figure are too large, they are too large. (However in future versions, a warning will be emitted in such cases, see #10915) You need to decide for yourself what outcome you wish to have. Either make sure the labels or title are short enough not to overlap the axes by using a smaller fontsize or wrapping the text. Or, if you need those long labels, call tight layout before setting the long text to labels. |
Closed by #10915. |
When plotting a lot of subplots (here 6), with long y-labels and tight_layout, the y-axis is reverted.
In this example, it is particularly striking as I am plotting histograms.
Expected outcome
Removing the tight layout, the labels collapse, but at least the plots are oriented the correct way.
Matplotlib should
either raise a proper errorraise a proper warning, or plot the histograms in the proper order.Matplotlib version
Matplotlib 2.0.0
The text was updated successfully, but these errors were encountered: