Trying to draw a line connecting a point on a 3D subplot to another 3D subplot. In 2D this is easy to do using ConnectionPatch. I've tried to mimic the Arrow3D class from here without luck.
I'm happy for even just a work-around at this point. As an example, in the figure generated by the code below I would want to connect the two green dots.
def cylinder(r, n):
'''
Returns the unit cylinder that corresponds to the curve r.
INPUTS: r - a vector of radii
n - number of coordinates to return for each element in r
OUTPUTS: x,y,z - coordinates of points
'''
# ensure that r is a column vector
r = np.atleast_2d(r)
r_rows, r_cols = r.shape
if r_cols > r_rows:
r = r.T
# find points along x and y axes
points = np.linspace(0, 2*np.pi, n+1)
x = np.cos(points)*r
y = np.sin(points)*r
# find points along z axis
rpoints = np.atleast_2d(np.linspace(0, 1, len(r)))
z = np.ones((1, n+1))*rpoints.T
return x, y, z
#---------------------------------------
# 3D example
#---------------------------------------
fig = plt.figure()
# top figure
ax = fig.add_subplot(2,1,1, projection='3d')
x,y,z = cylinder(np.linspace(2,1,num=10), 40)
for i in range(len(z)):
ax.plot(x[i], y[i], z[i], 'c')
ax.plot([2], [0], [0],'go')
# bottom figure
ax2 = fig.add_subplot(2,1,2, projection='3d')
x,y,z = cylinder(np.linspace(0,1,num=10), 40)
for i in range(len(z)):
ax2.plot(x[i], y[i], z[i], 'r')
ax2.plot([1], [0], [1],'go')
plt.show()
I was trying to solve a very similar problem just tonight! Some of the code may be unnecessary but it will give you the main idea... ...I hope
Inspiration from: http://hackmap.blogspot.com.au/2008/06/pylab-matplotlib-imagemap.html and other many and varied sources over the last two hours...
success http://i42.tinypic.com/5bpxyo.jpg
My final code, just to have a workable example: