scatter update with animation
<p>I am trying to do a real time scatter-kind plot using matplotlib's animation module but I'm quite a newbie with it. My objective is to update the plot whenever I receive the data I want to plot, so that any time data is received, previous points disappear and the new ones are plotted. </p>

<p>My program can be written like this if I substitute the data receiving with a endless loop and a random generation of data:</p>

<pre><code>fig = plt.figure()
skyplot = fig.add_subplot(111, projection='polar')
skyplot.set_ylim(90)  # sets radius of the circle to maximum elevation
skyplot.set_theta_zero_location("N")  # sets 0(deg) to North
skyplot.set_theta_direction(-1)  # sets plot clockwise
skyplot.set_yticks(range(0, 90, 30))  # sets 3 concentric circles
skyplot.set_yticklabels(map(str, range(90, 0, -30)))  # reverse labels
plt.ion()

while(1):

    azimuths = random.sample(range(360), 8)
    elevations = random.sample(range(90), 8)
    colors = numpy.random.rand(3,1)

    sat_plot = satellite()
    ani= animation.FuncAnimation(fig, sat_plot.update, azimuths, elevations, colors)

class satellite:

    def __init__(self):
        self.azimuths = []
        self.elevations = []
        self.colors = []
        self.scatter = plt.scatter(self.azimuths, self.elevations, self.colors)

    def update(self, azimuth, elevation, colors):
        self.azimuths = azimuth
        self.elevations = elevation
        return self.scatter
</code></pre>

<p>Right now, I'm getting the following error:</p>

<pre><code>&gt; Traceback (most recent call last):
  File "./skyplot.py", line 138, in &lt;module&gt;
    ani= animation.FuncAnimation(fig, sat_plot.update, azimuths, elevations, colors)
  File "/usr/lib/pymodules/python2.7/matplotlib/animation.py", line 442, in __init__
    TimedAnimation.__init__(self, fig, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/animation.py", line 304, in __init__
    Animation.__init__(self, fig, event_source=event_source, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/animation.py", line 53, in __init__
    self._init_draw()
  File "/usr/lib/pymodules/python2.7/matplotlib/animation.py", line 469, in _init_draw
    self._drawn_artists = self._init_func()
TypeError: 'list' object is not callable
</code></pre>

<p>Can anyone tell me what I'm doing wrong and how could I do this?</p>

<p>Thanks in advance</p>

<p>I think you do not need an animation. You need a simple endless loop (<code>while</code> for example) with plot update in a thread. I can propose something like this:</p>

<pre><code>import threading,time
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
data = np.random.uniform(0, 1, (5, 3))
plt.scatter(data[:, 0], data[:,1],data[:, 2]*50)

def getDataAndUpdate():
    while True:
        """update data and redraw function"""
        new_data = np.random.uniform(0, 1, (5, 3))
        time.sleep(1)
        plt.clf()
        plt.scatter(new_data[:, 0], new_data[:, 1], new_data[:, 2] * 50)
        plt.draw()

t = threading.Thread(target=getDataAndUpdate)
t.start()
plt.show()
</code></pre>

<p>The result is an animated-like figure with scatterplot.</p>

python animation matplotlib scatter-plot