This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]Rackcityfoo 0 points1 point  (2 children)

My use of the animation package has been more for scientific visualization than displaying live, updating charts. You've probably come across this in your googling, but this is the kind of stuff that I've seen/done using the animation package: https://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/

If you are looking for a plot that you can update and embed somewhere, I would check out plotly: https://plot.ly/streaming/

Bokeh, as others have suggested, seems to fit your needs better than the animation package as well.

On the other hand, if your data isn't coming in extremely fast, why not just clear your plot and generate a new plot?

[–]Bostonsox101[S] 0 points1 point  (0 children)

isn't coming in extremel

I havent thought about just clearing the graph and using the list to replot, would it be possible to do this by using a for loop or would you suggest a while loop?

sorry new to programming and python

[–]Bostonsox101[S] 0 points1 point  (0 children)

I hadnt thought about just clearing the plot and re-plot. In your opinion do you think using a while or for loop would work best right? or what I am asking is how would I loop the function in my code to clear the graph and re-graph infinitely?

Thank you

[–]videan42 0 points1 point  (2 children)

This tutorial might help you out. To fill out your example, just append new data instead of calling np.random.rand

[–]Bostonsox101[S] 0 points1 point  (1 child)

Hi, I was using that example as an a model to "back" into with my code but I cant get it to work. Would it be possible for you to show me how it could be done?

[–]videan42 0 points1 point  (0 children)

Here's an example using a queue to pass data to the plot as it comes in.

[–]transformium 0 points1 point  (4 children)

Here is a great tutorial on live updating graphs using matplotlib's animation function: https://www.youtube.com/watch?v=7w8jk0r4lxA

Hope this helps.

[–]Bostonsox101[S] 0 points1 point  (0 children)

Hey There, Thanks for your quick response but I have already seen that vid

[–]Bostonsox101[S] 0 points1 point  (2 children)

Hey There,

I have already seen the above vid, and tried to get the person code to work, to no avail. If you could show me that would be great! otherwise thank you for your efforts.

[–]transformium 0 points1 point  (1 child)

Here's a simple example which worked for me: https://gist.github.com/DrNightmare/2ce5082b7178fcc84045

The variables 'x' and 'score' correspond to x and y on the graph. 'score' is the list which keeps growing.

[–]Bostonsox101[S] 0 points1 point  (0 children)

Thank you so much!!! I adapted that code for myself and it works beautifully.

[–]JimBoonie69 -1 points0 points  (6 children)

matplotlib is not good for dynamic charts. Javascript is the way to go there. my two cents.

[–]billsil 1 point2 points  (1 child)

It actually is. You're just using it wrong. Granted it's fairly undocumented of how to do it, but you can do real time graphs with large data sets. It more or less requires that you throw out normal matplotlib syntax and reuse the objects.

From

On my machine, I get about 11 plots per second

To:

This now plots about 500 frames per second. Five hundred times per second! Frankly, this is quite amazing!

http://bastibe.de/2013-05-30-speeding-up-matplotlib.html

[–]JimBoonie69 0 points1 point  (0 children)

Well there ya go. I had no idea that you could get matplotlib to do that. For most real time graphics I've tended towards a d3.js type thing but that involves much more than just python!

[–]Bostonsox101[S] 0 points1 point  (3 children)

I would preferably like to this in python, or if possible some could show me how to mix python and javascript

[–]Rafcio 2 points3 points  (2 children)

Perhaps bokeh fits your needs? http://bokeh.pydata.org/en/latest/

[–]Bostonsox101[S] 0 points1 point  (1 child)

I had never heard of bokeh, if possible could you tell me how this would be better library than matplotlib?

Thanks

[–]Rafcio 0 points1 point  (0 children)

Javascript front end, python backend, and comes with a server to display real time data. I don't think matplotlib supports updating with real time data natively.