Skip to content

Figure.subfigures dont show/update correctly #19947

Closed
@lwelzel

Description

@lwelzel

Bug report

Bug summary
When using Figure.subfigures(n, m) for any n or m larger than 2 the resulting figure does not draw properly when shown.
Instead only the subfigures at [0:2, 0] and [0:2, -1] are drawn properly.

Code for reproduction

import matplotlib.pyplot as plt

fig = plt.figure()
sub_figs = fig.subfigures(3, 3)

colors = ["red", "blue", "magenta", "gold", "green", "grey", "orange", "pink", "navy", "lightblue", "black"]

for i, (color, subfig) in enumerate(zip(colors,sub_figs.flatten())):
    subfig.set_facecolor(color)
    subfig.suptitle(f"subfig: {i}")

plt.show()

######### for (n, m) figures

import matplotlib.pyplot as plt

fig = plt.figure()
sub_figs = fig.subfigures(9, 10)

for i, subfig in enumerate(sub_figs.flatten()):
    subfig.set_facecolor("grey")
    subfig.suptitle(f"subfig: {i}")

plt.show()

Actual outcome

image

Only the subfigures at [0:2, 0] and [0:2, -1] are drawn properly for any (n, m) figure.

Expected outcome
3x3 grid with the proper face colors. Similar results for 2x3 or 3x2 or larger grids.

Matplotlib version

  • Operating system: Fedora (UNIX)
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): 3.4.1
  • Matplotlib backend (print(matplotlib.get_backend())): module://backend_interagg
  • Python version: 3.7
  • Jupyter version (if applicable): NA
  • Other libraries: NA

Both python and Matplotlib from conda with manual update to Matplotlib version 3.4.1
conda channel: conda-forge

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.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