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

Already on GitHub? Sign in to your account

Unimplemented comparison method for Line3DCollection #1831

SmedbergM opened this Issue Mar 16, 2013 · 4 comments


None yet
3 participants

See Stackoverflow question

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)


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)
  File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 191, in draw
TypeError: unorderable types: Line3DCollection() < Line3DCollection()
Exception in Tkinter callback

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?


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:


I can not reproduce either problem on current-ish master (2.7, linux, ipython, qt4 backend).


WeatherGod commented May 14, 2013

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

@WeatherGod WeatherGod closed this May 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment