|
From: Benjamin R. <ben...@gm...> - 2015-09-28 15:43:55
|
Confirmed using a fairly recent matplotlib checkout. Could you file a bug
report? This is going to need some investigating.
As a side note though, the way you are updating the lines by calling
`ax.plot` repeatedly, is bad form. You want to update the lines object
itself, by calling its "set_data()" method. Also, move the call to
`ax.legend()` to after calling `ax.plot` to avoid the warnings about
unlabeled plotting objects.
On Sat, Sep 26, 2015 at 3:46 AM, Shakthi Kannan <sha...@gm...>
wrote:
> Hi,
>
> I am trying to create poly lines using matplotlib and animation. My
> code snippet is as follows:
>
> === BEGIN ===
>
> import matplotlib as mpl
> from mpl_toolkits.mplot3d import Axes3D
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib.animation as animation
>
> def update_line(num, x, y, z, l):
> x.append(1.0)
> y.append (2.0)
> z.append(3.0)
> print x, y, z
> l, = ax.plot(x, y, z, label='Line')
> return l,
>
> fig = plt.figure()
> ax = fig.gca(projection='3d')
> ax.set_xlabel('X')
> ax.set_ylabel('Y')
> ax.set_zlabel('Z')
> ax.legend()
>
> x = [1.0, 2.0, 3.0]
> y = [4.0, 7.0, 8.0]
> z = [6.0, 9.0, 5.0]
>
> l, = ax.plot(x, y, z, label='Line')
>
> line_ani = animation.FuncAnimation(fig, update_line, 25, fargs=(x, y,
> z, l), interval=2000, blit=True)
>
> plt.show()
>
> === END ===
>
> The error that I get:
>
> === ERROR ===
>
> $ python mat-3.py
>
> /usr/lib/pymodules/python2.7/matplotlib/axes.py:4747: UserWarning: No
> labeled objects found. Use label='...' kwarg on individual plots.
> warnings.warn("No labeled objects found. "
> [1.0, 2.0, 3.0, 1.0] [4.0, 7.0, 8.0, 2.0] [6.0, 9.0, 5.0, 3.0]
> Exception in Tkinter callback
> Traceback (most recent call last):
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1535, in __call__
> return self.func(*args)
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 586, in callit
> func(*args)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 363, in idle_draw
> self.draw()
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 348, in draw
> FigureCanvasAgg.draw(self)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py",
> line 451, in draw
> self.figure.draw(self.renderer)
> File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55,
> in draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 1034, in
> draw
> func(*args)
> File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.py",
> line 270, in draw
> Axes.draw(self, renderer)
> File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55,
> in draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 2086, in
> draw
> a.draw(renderer)
> File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/art3d.py",
> line 117, in draw
> xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
> File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/proj3d.py",
> line 194, in proj_transform
> return proj_transform_vec(vec, M)
> File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/proj3d.py",
> line 153, in proj_transform_vec
> vecw = np.dot(M, vec)
> TypeError: can't multiply sequence by non-int of type 'float'
> [1.0, 2.0, 3.0, 1.0, 1.0] [4.0, 7.0, 8.0, 2.0, 2.0] [6.0, 9.0, 5.0, 3.0,
> 3.0]
> Exception in Tkinter callback
> Traceback (most recent call last):
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1535, in __call__
> return self.func(*args)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 276, in resize
> self.show()
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 348, in draw
> FigureCanvasAgg.draw(self)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py",
> line 451, in draw
> self.figure.draw(self.renderer)
> File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55,
> in draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 1034, in
> draw
> func(*args)
> File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.py",
> line 270, in draw
> Axes.draw(self, renderer)
> File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55,
> in draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 2086, in
> draw
> a.draw(renderer)
> File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/art3d.py",
> line 117, in draw
> xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
> File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/proj3d.py",
> line 194, in proj_transform
> return proj_transform_vec(vec, M)
> File "/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/proj3d.py",
> line 153, in proj_transform_vec
> vecw = np.dot(M, vec)
> TypeError: can't multiply sequence by non-int of type 'float'
>
> === END ===
>
> I am using the basic_example.py as a template.
>
> http://matplotlib.org/1.4.1/examples/animation/basic_example.html
>
> What could I be missing? Appreciate any help in this regard,
>
> Thanks!
>
> SK
>
> --
> Shakthi Kannan
> http://www.shakthimaan.com
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
|