| 1 | [Bug]: 'Line3D' object has no attribute '_verts3d' |
| 2 | ### Bug summary |
| 3 | |
| 4 | I use matplotlib 3D to visualize some lines in 3D. When I first run the following code, the code can run right. But, if I give `x_s_0[n]` a numpy array, it will report the error 'input operand has more dimensions than allowed by the axis remapping'. The point is when next I give `x_s_0[n]` and other variables an int number, the AttributeError: 'Line3D' object has no attribute '_verts3d' will appear and can not be fixed whatever I change the variables or delete them. The error can be only fixed when I restart the kernel of ipython console. I don't know why it happens, so I come here for help. |
| 5 | |
| 6 | ### Code for reproduction |
| 7 | |
| 8 | ```python |
| 9 | x_s_0 = np.array(['my int number list']) |
| 10 | x_e_0 = np.array(['my int number list']) |
| 11 | y_s_0 = np.array(['my int number list']) |
| 12 | y_e_0 = np.array(['my int number list']) |
| 13 | z_s_0 = np.array(['my int number list']) |
| 14 | z_e_0 = np.array(['my int number list']) |
| 15 | |
| 16 | fig = plt.figure() |
| 17 | ax = fig.gca(projection='3d') |
| 18 | ax.view_init(elev=90, azim=0) |
| 19 | ax.set_zlim3d(-10, 10) |
| 20 | clr_list = 'r-' |
| 21 | |
| 22 | for n in range(np.size(z_s_0, axis=0)): |
| 23 | ax.plot([int(x_s_0[n]), int(x_e_0[n])], |
| 24 | [int(y_s_0[n]), int(y_e_0[n])], |
| 25 | [int(z_s_0[n]), int(z_e_0[n])], clr_list) |
| 26 | |
| 27 | plt.xlabel('x') |
| 28 | plt.ylabel('y') |
| 29 | # ax.zlabel('z') |
| 30 | plt.title('90-0') |
| 31 | plt.show() |
| 32 | ``` |
| 33 | |
| 34 | |
| 35 | ### Actual outcome |
| 36 | |
| 37 | Traceback (most recent call last): |
| 38 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3444, in run_code |
| 39 | exec(code_obj, self.user_global_ns, self.user_ns) |
| 40 | File "<ipython-input-80-e04907066a16>", line 20, in <module> |
| 41 | plt.show() |
| 42 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/pyplot.py", line 368, in show |
| 43 | return _backend_mod.show(*args, **kwargs) |
| 44 | File "/home/hanyaning/.pycharm_helpers/pycharm_matplotlib_backend/backend_interagg.py", line 29, in __call__ |
| 45 | manager.show(**kwargs) |
| 46 | File "/home/hanyaning/.pycharm_helpers/pycharm_matplotlib_backend/backend_interagg.py", line 112, in show |
| 47 | self.canvas.show() |
| 48 | File "/home/hanyaning/.pycharm_helpers/pycharm_matplotlib_backend/backend_interagg.py", line 68, in show |
| 49 | FigureCanvasAgg.draw(self) |
| 50 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 436, in draw |
| 51 | self.figure.draw(self.renderer) |
| 52 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/artist.py", line 73, in draw_wrapper |
| 53 | result = draw(artist, renderer, *args, **kwargs) |
| 54 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/artist.py", line 50, in draw_wrapper |
| 55 | return draw(artist, renderer) |
| 56 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/figure.py", line 2803, in draw |
| 57 | mimage._draw_list_compositing_images( |
| 58 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images |
| 59 | a.draw(renderer) |
| 60 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/artist.py", line 50, in draw_wrapper |
| 61 | return draw(artist, renderer) |
| 62 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 469, in draw |
| 63 | super().draw(renderer) |
| 64 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/artist.py", line 50, in draw_wrapper |
| 65 | return draw(artist, renderer) |
| 66 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 3082, in draw |
| 67 | mimage._draw_list_compositing_images( |
| 68 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images |
| 69 | a.draw(renderer) |
| 70 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/matplotlib/artist.py", line 50, in draw_wrapper |
| 71 | return draw(artist, renderer) |
| 72 | File "/home/hanyaning/anaconda3/envs/SBeA/lib/python3.8/site-packages/mpl_toolkits/mplot3d/art3d.py", line 215, in draw |
| 73 | xs3d, ys3d, zs3d = self._verts3d |
| 74 | AttributeError: 'Line3D' object has no attribute '_verts3d' |
| 75 | |
| 76 | ### Expected outcome |
| 77 | |
| 78 | Some 3D lines |
| 79 | |
| 80 | ### Additional information |
| 81 | |
| 82 | _No response_ |
| 83 | |
| 84 | ### Operating system |
| 85 | |
| 86 | Local: windows + pycharm, Remote: Ubuntu 20.04 |
| 87 | |
| 88 | ### Matplotlib Version |
| 89 | |
| 90 | 3.5.0 |
| 91 | |
| 92 | ### Matplotlib Backend |
| 93 | |
| 94 | module://backend_interagg |
| 95 | |
| 96 | ### Python version |
| 97 | |
| 98 | 3.8.12 |
| 99 | |
| 100 | ### Jupyter version |
| 101 | |
| 102 | _No response_ |
| 103 | |
| 104 | ### Installation |
| 105 | |
| 106 | pip |