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
[Bug]: Mosaic Scaling #23290
Comments
attn @jklymak |
Thanks for the report. The dance that has to happen when axes have staggered limits like this is a bit delicate, and clearly doesn't work in this case. Its probably fixable. What does work is to keep the two in a separate subfigures: left = [['L1'], ['L2']]
right = [['R1'], ['R2'], ['R3']]
mosaic = [[left, right]] |
... there is a workaround, so I'll milestone 3.6, though it could easily go in a 3.6 point release as well. I probably can fix this, but it may take some tinkering. |
I'm tempted to leave this as wont-fix. In this case, the left hand column has no internal spines in common w/ the righthand column, so it is not particularly useful for them to be in the same layout, and constrained_layout was designed to make lined-up layouts taking into account different decorations on each axes. tight_layout just makes all the spaces around the axes the same, and set by the largest decoration I'm not arguing that what the OP was doing was at all wrong, but just one of those cases for which constrained_layout is ill-suited. Again, if you use subfigures or nested mosaics you can get what you want, or you can fallback on tight_layout. We can keep this open because we should document this case as a time when constrained_layout fails for the |
@jklymak is there a way to detect such cases so that we can issue a waning, possibly with a hint what to do instead. |
I'm not sure. It's probably possible to post process the positions returned and decide if there are problems. The array of possible problems is pretty undefined, however. Just to be clear; constrained layout did what we told it to here - it's just that when you span a subplot across subplotspec slots it gets the margins it subsumes as well. Because there are an odd number is subplots in the left column the right column lines up differently for the two subplots. I think the general warning is that spanning subplotspecs works for many cases, but is fragile in general. |
The detection does not have to be exhausting. We don't want false-positive alerts. But it's ok not to wan in every problematic situation. It's already helpful to detect some common specific cases and warn on them. |
Bug summary
I think "constrained_layout=True" breaks the mosaic scaling. For example subplot D is smaller than subplot E in the "Actual Outcome". When I use plot.tight_layout() and contrained_layout=False the subplots are the same size as in the "Expected Outcome"
Code for reproduction
Actual outcome
Expected outcome
Additional information
No response
Operating system
OS/X
Matplotlib Version
3.5.1
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.9.12
Jupyter version
3.3.2
Installation
conda
The text was updated successfully, but these errors were encountered: