This may be a bit crazy, but I'm trying to create a clickable image map of a 3d scatter plot using matplotlib v1.1.0. I've read how to do it for 2d plots (c.f. this blog), but 3d has mystified me. The basic problem is I don't know how to get the display coordinates for a 3d axes.
In the 2d case, in order to get the click points correctly located over the scatter points, you need to convert each scatter point from data units to display units. That seems fairly straight forward using ax.transData. I was hoping this would also work for 3d axes, but it appears not. For example, here's what I have tried to do:
# create the plot
from mpl_toolkits.mplot3d import Axes3D
fig = pylab.figure()
ax = fig.add_subplot(111, projection = '3d')
x = y = z = [1, 2, 3]
sc = ax.scatter(x,y,z)
# now try to get the display coordinates of the first point
sc.axes.transData.transform((1,1,1))
The last line gives me an "Invalid vertices array" error, however. It only works if you pass it a tuple of two points, e.g., (1,1), but that doesn't make sense for a 3d plot. There must be a method somewhere that converts the 3d projection to 2d display coordinates, but after wracking the internet for a couple hours I can't find it. Does anyone know how to correctly do this?