matplotlib / matplotlib/ipympl
What prevents a figure showing before notebook cell completion?
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 1.7k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
My issue boils down to:
"Why does the figure not show immediately, but instead waits until the cell has completed running?"
%matplotlib widget
import matplotlib.pyplot as plt
from time import sleep
fig = plt.figure()
plt.plot([1,2,3])
sleep(2)
This behaviour is preventing fun uses, like dynamic plotting in a single cell:
%matplotlib widget
from matplotlib import pyplot as plt
from time import sleep
import numpy as np
fig = plt.figure()
for i in range(10):
x, y = np.random.random(2)
plt.scatter(x, y)
fig.canvas.draw()
sleep(0.1)
The previous code works if one splits it into two cells, placing the figure() call in the first one:
# Cell 1
%matplotlib widget
from matplotlib import pyplot as plt
from time import sleep
import numpy as np
fig = plt.figure()
# Cell 2
for i in range(10):
x, y = np.random.random(2)
plt.scatter(x, y)
fig.canvas.draw()
sleep(0.1)
Edit: I also note that in the qt backend, there figure and plot are shown immediately, in contrast to the ipympl behaviour.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source files or tests. Start by reproducing the single-cell and split-cell examples with the %matplotlib widget backend, then compare the fig.canvas.draw() behavior with the Qt backend; done means the cause and an appropriate rendering behavior are established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter, jupyter-notebook, python
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100