display `print` in callbacks in the notebook
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- jupyter, jupyter-notebook, python
- Domain
- data-visualization, frontend
Research direction
The issue provides a Python callback using fig.canvas.mpl_connect and an ipywidgets.Output workaround; start by reproducing the missing print output in JupyterLab with ipympl and compare it with IPython. Done means print output from matplotlib callbacks appears automatically in the notebook without wrapping the callback in an Output context.
Written by the indexing model from the issue text.
Description
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
n = 0
def printer(event):
global n
print(f'in event {event}')
n += 1
fig.canvas.mpl_connect('button_press_event', printer)
when run in IPython prints out to stdout on every mouse click. In jlab + ipympl the prints don't show up anywhere I can find...
From https://ipywidgets.readthedocs.io/en/stable/examples/Output%20Widget.html it looks like this can work via:
output = widgets.Output()
display(fig.canvas, output)
n = 0
def printer(event):
global n
with output:
print(f'in event {event}')
n += 1
fig.canvas.mpl_connect('button_press_event', printer)
but I suspect there is a way for this to work automatically....
- Dominant language
- Jupyter Notebook
- Stars
- 1.7k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
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.
More from matplotlib/ipympl
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
matplotlib/ipympl#623 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
matplotlib/ipympl#622 · 13 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
matplotlib/ipympl#612 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
matplotlib/ipympl#611 · 4 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
matplotlib/ipympl#609 · 7 comments ·
All issues in matplotlib/ipympl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
pydata/pydata-sphinx-theme#2503 ·
-
bug triage_needed
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
P3 size: 1 task
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 88/100