Skip to content

Fix MatPlot.clear() crash with matplotlib 3.11+#229

Merged
jenshnielsen merged 1 commit into
pre-commit-ci-update-configfrom
copilot/main
Jun 16, 2026
Merged

Fix MatPlot.clear() crash with matplotlib 3.11+#229
jenshnielsen merged 1 commit into
pre-commit-ci-update-configfrom
copilot/main

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

matplotlib 3.11 added a guard in plt.subplots() that raises ValueError when called with an already-existing figure number unless clear=True is passed. MatPlot.clear() triggered this by calling _init_plot(..., num=self.fig.number) after fig.clf() — the figure remains registered even after being cleared.

Change

  • qcmatplotlib.py: pass clear=True to both plt.subplots() calls in _init_plot(), eliminating the ValueError: Figure {num!r} already exists error on MatPlot.clear().

Pass clear=True to plt.subplots() in _init_plot so that reusing a
figure number (as done in MatPlot.clear()) no longer raises a
ValueError in matplotlib >= 3.11.
Copilot AI changed the title Fix matplotlib clear() ValueError with matplotlib 3.11+ Fix MatPlot.clear() crash with matplotlib 3.11+ Jun 16, 2026
Copilot AI requested a review from jenshnielsen June 16, 2026 06:50
@jenshnielsen jenshnielsen marked this pull request as ready for review June 16, 2026 07:06
@jenshnielsen jenshnielsen merged commit 7e87862 into pre-commit-ci-update-config Jun 16, 2026
9 checks passed
@jenshnielsen jenshnielsen deleted the copilot/main branch June 16, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants