question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plt.pause uses removed `start_event_loop_default` API

See original GitHub issue

As the title suggests, attempting to pause through matplotlib currently raises an error. The minimum working example is:

%matplotlib widget
from matplotlib import pyplot as plt

plt.plot([1,2,3])
plt.pause(1)    
plt.plot([3,2,1])
plt.close()

This raises an attribute error trying to call FigureCanvasBase.start_event_loop_default. A little googling suggests this function has been removed since version 3.0.

Taking inspiration from #17, I guess the simplest get around is using time.sleep but is there a better solution?

Thanks for your help.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ArEsKay3commented, Jun 19, 2019

I’m not sure sleep works for me because in my case I want to pause for matplotlib event handling.

In my case I have code running in a loop that needs to periodically update the plot and get mouse events from the plot.

Is this a problem in jupyter-matplotlib or in matplotlib in general?

0reactions
ianhicommented, Sep 26, 2020

@Michael-Equi I think my proposed solution should work pretty well as a permanent fix. The issue is that it has remained as “proposed” and never made it all the way to implemented

Read more comments on GitHub >

github_iconTop Results From Across the Web

matplotlib.pyplot.pause — Matplotlib 3.6.2 documentation
If there is an active figure, it will be updated and displayed before the pause, and the GUI event loop (if any) will...
Read more >
python - Is there a way to detach matplotlib plots so that the ...
I may use something like a time-out-question "End of script! \nPress p if you want the plotting output to be paused (you have...
Read more >
matplotlib.pyplot.pause() in Python - GeeksforGeeks
The pause() function in pyplot module of matplotlib library is used to pause for interval seconds. Syntax: matplotlib.pyplot.pause(interval).
Read more >
How To Clear A Plot In Python (without closing the window)
Click to clear a plot using two methods - clearing Pyplot Figure or ... Matplotlib's pyplot API is stateful, which means that it...
Read more >
Speeding up Matplotlib - Bastibe.de
import matplotlib.pyplot as plt import numpy as np import time fig, ... I am using pause() here to update the plot without blocking....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found