Skip to content

fig.suptitle overlapping with axis using constrained_layout #13672

@asteppke

Description

@asteppke

I want to add a title to a matplotlib figure. Using the newer constrained_layout the title is nicely aligned with the axis.

Unfortunately under certain circumstances the layout still overlaps as shown in the following examples in the Jupyter notebook (with different backends):

%matplotlib notebook 
import numpy as np
from matplotlib import pyplot as plt

# example with low height
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(6, 3), constrained_layout=True)
axes[0,0].plot([0,1,2], label='test')
axes[1,0].plot([0,1,2], label='test 2')
fig.suptitle('a longer title') 

This results in
image

But now increasing the plot height using the modified example

[...]
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(6, 12), constrained_layout=True)
[...]

shows the following overlapping title:

image

Is there anything that can be done here to find out why this is not taking into account the larger plot dimensions?

Originally posted by @asteppke in #5355 (comment)

Metadata

Metadata

Assignees

Labels

topic: geometry managerLayoutEngine, Constrained layout, Tight layout

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy