Skip to content

[Bug]: Constrained Layout scaling of layouts with submerged spines #23290

@lswenson

Description

@lswenson

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

import matplotlib.pyplot as plt
import matplotlib as mpl

def identify_axes(ax_dict, fontsize=48):
    """
    Helper to identify the Axes in the examples below.

    Draws the label in a large font in the center of the Axes.

    Parameters
    ----------
    ax_dict : dict[str, Axes]
        Mapping between the title / label and the Axes.
    fontsize : int, optional
        How big the label should be.
    """
    kw = dict(ha="center", va="center", fontsize=fontsize, color="darkgrey")
    for k, ax in ax_dict.items():
        ax.text(0.5, 0.5, k, transform=ax.transAxes, **kw)

mosaic = """AAADDD
            AAADDD
            BBBDDD
            BBBEEE
            CCCEEE
            CCCEEE"""
fig = plt.figure(constrained_layout=True)
ax_dict = fig.subplot_mosaic(mosaic)
identify_axes(ax_dict)

Actual outcome

Screen Shot 2022-06-16 at 14 59 13

Expected outcome

Screen Shot 2022-06-16 at 15 02 03

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions