# Unimplemented comparison method for Line3DCollection #1831

Closed
opened this Issue Mar 16, 2013 · 4 comments

Projects
None yet
3 participants

### SmedbergM commented Mar 16, 2013

 When creating/manipulating 3D wireframe plots, an axes3d will create and then sort a list of its collections. However, Line3DCollection objects don't have an implemented comparison method, which causes uncaught exceptions. (Sadly, this is a finicky bug, so I needed a fairly complex example, and even that didn't reproduce on someone else's machine.) This example was produced in an Ipython QT console session, under Python 3.2 and mpl version 1.2.0 with Tkinter backend. ``````from mpl_toolkits.mplot3d import Axes3D A,B,C,D = np.array([[0,0],[1,0],[1/2,1],[3/2,1]]) f1 = lambda x,y: np.NaN if x==y==0 else (y - 2*x)*np.sin(1/(x**2+y**2)) f2 = lambda x,y: np.NaN if x==y==0 else (y-2*x+2)*np.cos(1/(x**2+y**2)) (U,V) = np.meshgrid(np.linspace(0,1),np.linspace(0,1)) fig = plt.figure(1) ax = fig.add_subplot(111,projection = '3d') (X1,Y1) = np.vectorize(lambda u,v: tuple(A + u*(B-A) + u*v*(C-B)), otypes = [np.float,np.float])(U,V) (X2,Y2) = np.vectorize(lambda u,v: tuple(D + u*(C-D) + u*v*(B-C)), otypes = [np.float,np.float])(U,V) Z11 = np.vectorize(f1)(X1,Y1) Z21 = np.vectorize(f2)(X1,Y1) Z12 = np.vectorize(f1)(X2,Y2) Z22 = np.vectorize(f2)(X2,Y2) ax.plot_wireframe(X1,Y1,Z11) ax.plot_wireframe(X1,Y1,Z21) ax.plot_wireframe(X2,Y2,Z12) ax.plot_wireframe(X2,Y2,Z22) plt.show() `````` On mouse-click in the figure window, I get the following Tkinter exception trace: ``````Exception in Tkinter callback Traceback (most recent call last): File "C:\Python32\lib\tkinter\__init__.py", line 1399, in __call__ return self.func(*args) [snip] File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 191, in draw zlist.sort() TypeError: unorderable types: Line3DCollection() < Line3DCollection() Exception in Tkinter callback ``````
Owner

### tacaswell commented May 8, 2013

 Another instance of the same underlying issue I believe: http://stackoverflow.com/questions/16451147/matplotlib-contourf3d-demo2-example-doesnt-work-with-python3-3#16451147
Member

### WeatherGod commented May 14, 2013

 I have attempted to reproduce this in both 2.7 and 3.2 which I had available to me, and I can not. I would like to get this to a reproducible state. Have you noticed a difference between using iPython and regular python?
Owner

### tacaswell commented May 14, 2013

 I lost track of things when I added the other link, the OP reports upgrading to 1.2.1 fixed the problem: http://stackoverflow.com/questions/15441695/matplotlib-tkinter-bug-exception-when-comparing-collection3d-objects#comment22360796_15441695 I can not reproduce either problem on current-ish master (2.7, linux, ipython, qt4 backend).
Member

### WeatherGod commented May 14, 2013

 ok, then I will close this bug report. If it happens again, though, do let us know.