How to autoscale an animation?

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>

You are calling auto scale on the scatter artist which is trying to scale
the data for color mapping the scatter. You want to be calling auto scale
on the Axes (in this case I think axarr[0, 4]).

Tom

···

On Thu, Jul 13, 2017, 12:40 David Aldrich <David.Aldrich at emea.nec.com> wrote:

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

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170714/76c442ac/attachment.html&gt;