Matplotlib python animation not showing line
<p>The windows for plotting shows up but nothing appears and i get this ValueError: x and y must have same first dimension </p>

<pre><code>import psutil
import matplotlib.pyplot as plt
import matplotlib.animation as animation

a = [i for i in range(1000)]
ram_avaliable = []
fig, ax = plt.subplots()

def update(n):
    ram = psutil.virtual_memory()
    ram_avaliable.append(float(ram[1])/1073741824)
    print (a[n],ram_avaliable[n])
    ax.plot(a[n],ram_avaliable[n])

ani = animation.FuncAnimation(fig,update,interval=100)
plt.show()
</code></pre>

<p>Your code as posted runs without errors for me. The only change I had to make for points to show up was add a marker style to the <code>plot</code> command.</p>

<p>This is because when you call <code>plot</code> you are plotting a <em>new line</em>. The reason it wasn't showing up before is because the default line style is to connect points with lines - since there is only one point per plotted line, there's nothing to connect to. Changing the marker style to one that shows points fixes this, e.g.</p>

<pre><code>ax.plot(a[n],ram_avaliable[n], 'ro')
</code></pre>

<p>causes points to be plotted in red circles.</p>

python matplotlib