-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
matplotlib dynamic plotting #7759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think you may need to add |
Thank you very much Pete
It works now !
It triggers an alarm, but it works :
/usr/local/lib/python3.5/dist-packages/matplotlib/backend_bases.py:2437:
MatplotlibDeprecationWarning: Using default event loop until function specific to this GUI is implemented
warnings.warn(str, mplDeprecation)
Do you know why plt.pause() allows dynamic plots ?
De: "Pete Huang" <notifications@github.com>
À: "matplotlib/matplotlib" <matplotlib@noreply.github.com>
Cc: "pierre campistron" <pierre.campistron@univ-valenciennes.fr>, "Author" <author@noreply.github.com>
Envoyé: Samedi 7 Janvier 2017 16:29:36
Objet: Re: [matplotlib/matplotlib] matplotlib dynamic plotting (#7759)
I think you may need to add plt.pause(0.01) after plt.draw() - can you try that?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub , or mute the thread .
|
I'm entirely the wrong person to ask for the "why", but I'm glad it works! I just shuttled around StackOverflow for the answer :) |
'why' is a bit of a long question (see #4779 for an old PR trying to document all of the details). In very short, we made many of the GUI embedding more asynchronous, that is calling Doing import matplotlib.pyplot as plt
plt.ion()
import numpy as np
x = np.arange(128)
fig, ax = plt.subplots()
for it in range(5):
ax.plot(x, x+it)
# fig.canvas.draw_idle() # required to work on mpl < 1.5
fig.canvas.flush_events()
time.sleep(1)
plt.ioff()
plt.show() should do what you want. |
Thank you very much Thomas
It works perfectly, and I can zoom on figure during the loop !
I understand a little better now ;)
Best regards
Pierre
De: "Thomas A Caswell" <notifications@github.com>
À: "matplotlib/matplotlib" <matplotlib@noreply.github.com>
Cc: "pierre campistron" <pierre.campistron@univ-valenciennes.fr>, "Author" <author@noreply.github.com>
Envoyé: Samedi 7 Janvier 2017 22:07:19
Objet: Re: [matplotlib/matplotlib] matplotlib dynamic plotting (#7759)
'why' is a bit of a long question (see #4779 for an old PR trying to document all of the details). In very short, we made many of the GUI embedding more asynchronous, that is calling plt.draw calls fig.canvas.draw_idle() which asks the GUI to re-render the figure. If you never turn control over to the GUI event loop to process it's events, then it does not have a chance to update it's self (you will also note that while your code is running you can not pan/zoom the figure).
Doing
import matplotlib.pyplot as plt
plt.ion() import numpy as np
x = np.arange( 128 )
fig, ax = plt.subplots() for it in range ( 5 ):
ax.plot(x, x + it) # fig.canvas.draw_idle() # required to work on mpl < 1.5 fig.canvas.flush_events()
time.sleep( 1 )
plt.ioff()
plt.show()
should do what you want.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub , or mute the thread .
|
👍 Should we close this? |
Yes, I think that the problem is solved.
Many thanks for all you
De: "Pete Huang" <notifications@github.com>
À: "matplotlib/matplotlib" <matplotlib@noreply.github.com>
Cc: "pierre campistron" <pierre.campistron@univ-valenciennes.fr>, "Author" <author@noreply.github.com>
Envoyé: Dimanche 8 Janvier 2017 17:40:22
Objet: Re: [matplotlib/matplotlib] matplotlib dynamic plotting (#7759)
👍
Should we close this?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub , or mute the thread .
|
Hey guys, any idea on how to fix my equivalent I have set up a server that will read in live data and produce two 3d plots. You can run this simulated code below (instead of reading in the data from the client).
You guys have a better handle on how to fix this issue. Currently when I run the live plot (randomly sending over numbers), I can change the viewing angle with my cursor but I can't zoom in or out. I tried adding in I also noticed that when my plot isn't receiving live data, the window is unresponsive. I.e. If you try to maximize the window or change the window size the whole screen gets blurred. I have a feeling that this has something to do with me putting the plotting thread to sleep but maybe there's a simple fix? |
This question is probably better sent to the mailing list (matplotlib-users@python.org ; you will have to subscribe to post). #4779 may also be informative reading. |
Hi, after computer change, matplotlib don't work dynamically.
Before, it was able to update the figure at each iteration of a loop. Today only the last data are plotted.
Configuration :
HP zBook 15 G3 with NVidia Quadro
###Bug report
Bug summary
A figure inside a loop are not updated at each step
Code for reproduction
Expected outcome
Matplotlib version
1.5.1
Python version
3.5.2
OS
Ubuntu 16.04 LTS
The text was updated successfully, but these errors were encountered: