posit-dev / posit-dev/positron

2nd plt.figure doesn't show up with .py files and `%matplotlib ipympl`

Open
#8,020 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: plots lang: python
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 9h
Merged PRs (30d)
195

Description

System details:

Positron and OS details:

Positron Version: 2025.06.0 (Universal) build 167
Code - OSS Version: 1.100.0
Commit: e7e5d5590adc6bf7b760f837051cd2f57ea9e3dc
Date: 2025-05-29T20:44:08.369Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin arm64 23.5.0

Interpreter details:

Python 3.13.2

Describe the issue:

Take the following code and put it in a .py file:

import matplotlib.pyplot as plt
import numpy as np
plt.figure()
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(3*x)
plt.plot(x, y)
plt.figure()
plt.plot(x, np.exp(3*x))

Now create a new console, run "%matplotlib ipympl" and run the file. Only the second plot shows up. If you restart the console and just copy paste this code (after running %matplotlib ipympl) it works fine, likewise if the file is renamed to .ipy instead of .py (again after running %matpl...)

Were there any error messages in the UI, Output panel, or Developer Tools console?

Not error messages, but there was a slight difference in output. Here's the output for running .py:

Image

And here's the output for running .ipy:

Image

It seems that in the .ipy there's two iframes getting launched, but only one for the .py

Please let me know if I can be of any further assistance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in Positron with the provided Python code, first as a .py file and then as a .ipy file, after enabling %matplotlib ipympl. Compare how each run creates the plot output and iframes; done when both figures display for the .py case without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.