Skip to content

[Bug]: QtAgg - "Configure subplots" button immediately moves subplots #28553

@rcomer

Description

@rcomer

Bug summary

I was playing with @timhoffm's new example at #28546 and found that, with QtAgg, when I hit the "configure subplots" button the image subplots immediately move downwards.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

from matplotlib import colors

np.random.seed(19680801)

datasets = [
    (i+1)/10 * np.random.rand(10, 20)
    for i in range(4)
]

fig, axs = plt.subplots(2, 2)
fig.suptitle('Multiple images')

# create a single norm to be shared across all images
norm = colors.Normalize(vmin=np.max(datasets), vmax=np.min(datasets))

images = []
for ax, data in zip(axs.flat, datasets):
    images.append(ax.imshow(data, norm=norm))

fig.colorbar(images[0], ax=axs, orientation='horizontal', fraction=.1)

plt.show()

Actual outcome

Initially I get the expected plot
image

but when I hit the "Configure subplots" button, without changing any subplot settings I have

image

Expected outcome

Subplots don't move until I tell them!

Additional information

I have reproduced this back to v3.6.3 with QtAgg (I haven't tested further back). I cannot reproduce with TkAgg.

Operating system

Ubuntu

Matplotlib Version

main, 3.8.4, 3.6.3

Matplotlib Backend

QtAgg

Python version

3.9.19, 3.12.3, 3.11.6

Jupyter version

N/A

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions