[Matplotlib-users] How to autoscale an animation?

David Aldrich David.Aldrich at EMEA.NEC.COM
Thu Jul 13 12:55:22 EDT 2017


Hi

I am having difficulty autoscaling a subplot in an animation.  A snippet of my code is:

fig, axarr = plt.subplots(nrows=2, ncols=5, figsize=(12, 6))
sc_dl_layer1 = axarr[0,4].scatter(x_data, y_data, c='r', s=4)

def updatePlots(i):
               <snip>
               sc_dl_layer1.set_offsets(np.c_[i_data_layer_1, q_data_layer_1])
sc_dl_layer1.autoscale()

ani = matplotlib.animation.FuncAnimation(fig, updatePlots, frames=None, interval=200, repeat=True)
plt.show()

This code returns:

  sc_dl_layer1.autoscale()
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\matplotlib\cm.py", line 334, in autoscale
    raise TypeError('You must first set_array for mappable')
TypeError: You must first set_array for mappable

How can I fix this please?

Best regards

David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170713/dc2fab8b/attachment.html>


More information about the Matplotlib-users mailing list