I'm trying to create two 3D suplots side-by-side that I can easily compare visually. I'd like to be able to link their axes so that when I rotate, translate or zoom on one of them in pyplot's interactive graph, the other one will rotate, translate or zoom the same way. I tried telling the figure to share(xyz) like I would have done in a 2D plot but they aren't doing what I expect. They don't seem to be linked. Can someone help?
from mpl_toolkits.mplot3d.axes3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
from mpl_toolkits.mplot3d.axes3d import get_test_data
# Twice as wide as it is tall.
fig = plt.figure(figsize=plt.figaspect(0.5))
#---- First subplot
ax1 = fig.add_subplot(1, 2, 1, projection='3d')
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
surf1 = ax1.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
ax1.set_zlim3d(-1.01, 1.01)
#---- Second subplot that I want to share axis with first subplot
ax2 = fig.add_subplot(1, 2, 2, projection='3d',sharex = ax1,sharey = ax1,sharez = ax1)
surf2 = ax2.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
plt.show()