1
$\begingroup$

Is it better matplotlib interactive mode or matplotlib animation in terms of performance?

I have a continous flow of data coming from the serial port. I get 2 measures let's say var1 and var2. I need to plot them in a 3d plot adding the 3th dimension, the time. I've tried different approches based on ion, but i couldn't get what i want. I've seen many examples of animation, but no one is suitable for my purpose. I was arguing which one ion or animate is quicker, since the flow of data has a high frequency update. So i need to update data var1 as x and var2 as y and have a sliding z axis, the time is flowing.

Also, is there a something similar to "set_xdata" in a 3d plot?

$\endgroup$
10
  • $\begingroup$ matplotlib interactive mode or matplotlib animation Do you mean interactive vs. script, the different backend, or creating animations directly in or without matplotlib? What do you want to achieve in both cases? $\endgroup$
    – sebix
    Apr 25 '15 at 19:39
  • $\begingroup$ i mean this for interactive, usualy followed by matplotlib.pyplot.draw(). i mean this for animate $\endgroup$
    – arj
    Apr 25 '15 at 19:45
  • $\begingroup$ i need to know which one is better in performance, since i need to plot a flow of continous data from the serial (or socket). $\endgroup$
    – arj
    Apr 25 '15 at 19:51
  • 2
    $\begingroup$ I don't get it. Please describe your situation, problems, experience and desired output in detail. $\endgroup$
    – sebix
    Apr 25 '15 at 19:53
  • $\begingroup$ I have a continous flow of data coming from the serial port. I get 2 measures let's say var1 and var2. I need to plot them in a 3d plot adding the 3th dimension, the time. I've tried different approches based on ion, but i couldn't get what i want. I've seen many examples of animation, but no one is suitable for my purpose. I was arguing which one ion or animate is quicker, since the flow of data has a high frequency update. So i need to update data var1 as x and var2 as y and have a sliding z axis, the time is flowing. $\endgroup$
    – arj
    Apr 26 '15 at 7:50
1
$\begingroup$

matplotlib.animation is a nice approach because you can specify the frame or update rate. Here you have an example of a 3d animation, including a comment about set_data for 3D plots:

http://matplotlib.org/1.4.3/examples/animation/simple_3danim.html

Here you have another example plotting data coming from an Arduino board:

https://gist.github.com/electronut/d5e5f68c610821e311b0

In general, using your own logic mixing plt.ion, plt.draw and such is more complicated than using matplotlib.animation, so I recommend you to use the latter because it is specifically meant for this kind of task and I guess the performance would be better.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.