Subplot_mosaic constrained_layout problem

Hi Folks,

I’ve been experimenting with the new subplot_mosaic functionality( loving the simplicity, btw) and I’ve hit a problem.

With this layout, constrained_layout=True copes just fine.

layout = “”"
BCCE
BCCE
BADE
“”"
However, with this layout (extending D to a 2x1), I get the warning shown below

layout = “”"
BCCE
BCCE
BADD
“”"

[WARNING]
UserWarning: constrained_layout not applied. At least one axes collapsed to zero width or height.

Can someone explain to me what might cause this?

Incidentally, D is just a stacked bar graph

2020-11-15-195009_1920x1080_scrot

and E is a simple bar graph.

I also get the same warning when I extend A to (2x1) instead of extending D.

layout = “”"
BCCE
BCCE
BAAD
“”"

Cheers
Laurence

Can you try this from the default branch? @jklymak completely re-wrote how the we set up the constraints to avoid this sort of collapse (see https://github.com/matplotlib/matplotlib/pull/17494 for details).

This problem is at the Axes layout level and should be independent of what is in the Axes.

yes, this indeed fails to converge for 3.3.3, but works fine on master (3.4.0).

The problem here is a difficult one to set up constraints for - the CEAD axes all need to have matching sizes (C==D, A==E) but they do not share inner axes edges. Fixing this case was actually a good whack of relatively complicated code in _constrained_layout.py called _match_submerged_margins. Along with colorbars, it turns what should be 20 lines of code into a few hundred.

1 Like

Thanks Thomas/Jody

Useful to know this is a failure mode of the constrained_layouts, and not just something I’ve overlooked in my code.

When is 3.4.0 pencilled in for official release? - It’s not available to me in Google Colab via %pip ATM. (not urgent - just a request for info)

Cheers
Laurence

Aiming for sometime in January 2021 (with an RC in mid December 2020).