Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current demo2.py AttributeError: 'list' object has no attribute 'shape' #68

Open
thomasclifford opened this issue Mar 4, 2021 · 1 comment

Comments

@thomasclifford
Copy link

Good day and thanks for your work.
I'm trying to run the demo2.py to get the rotating 3d image, and the image window does appear
with the axes, but no drawing of the rotating figure.
I'm getting a traceback:

Exception in Tkinter callback
Traceback (most recent call last):
File "c:\bin\python38\lib\tkinter_init_.py", line 1883, in call
return self.func(*args)
File "c:\bin\python38\lib\tkinter_init_.py", line 804, in callit
func(*args)
File "c:\bin\python38\lib\site-packages\matplotlib\backends_backend_tk.py", line 253, in idle_draw
self.draw()
File "c:\bin\python38\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 9, in draw
super(FigureCanvasTkAgg, self).draw()
File "c:\bin\python38\lib\site-packages\matplotlib\backends\backend_agg.py", line 407, in draw
self.figure.draw(self.renderer)
File "c:\bin\python38\lib\site-packages\matplotlib\artist.py", line 41, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "c:\bin\python38\lib\site-packages\matplotlib\figure.py", line 1870, in draw
self.canvas.draw_event(renderer)
File "c:\bin\python38\lib\site-packages\matplotlib\backend_bases.py", line 1759, in draw_event
self.callbacks.process(s, event)
File "c:\bin\python38\lib\site-packages\matplotlib\cbook_init_.py", line 229, in process
self.exception_handler(exc)
File "c:\bin\python38\lib\site-packages\matplotlib\cbook_init_.py", line 81, in exception_printer
raise exc
File "c:\bin\python38\lib\site-packages\matplotlib\cbook_init
.py", line 224, in process
func(*args, **kwargs)
File "c:\bin\python38\lib\site-packages\matplotlib\animation.py", line 975, in _start
self._init_draw()
File "c:\bin\python38\lib\site-packages\matplotlib\animation.py", line 1722, in _init_draw
self._drawn_artists = self._init_func()
File "demo2-new.py", line 89, in init
line.set_3d_properties([])
File "c:\bin\python38\lib\site-packages\mpl_toolkits\mplot3d\art3d.py", line 143, in set_3d_properties
zs = np.broadcast_to(zs, xs.shape)
AttributeError: 'list' object has no attribute 'shape'

Windows 10

Python: 3.8.6
matplotlib: 3.3.4
numpy: 1.20.1
pyquaternion: 0.9.9

I found one post on stackoverflow that says to use numpy.array, but you're doing that already.
Thank you again.......
Tom C.

@j1s1e1
Copy link

j1s1e1 commented Jul 31, 2021

IF anyone else runs into this, it can be fixed by wrapping both the x and y data in the set_data statements with np.array. Change these two lines to the following:

currently on line 80 in def init():
line.set_data(np.array([]), np.array([]))

currently on line 98 in def animate(i):
line.set_data(np.array([start[0], end[0]]), np.array([start[1], end[1]]))

After that the demo should work.

Thanks,

James

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants