I want to plot a surface and zoom to a specific part of it. I have:
r1 = np.arange(10)
r2 = np.arange(15)
x, y = np.meshgrid(r2,r1)
z = np.random.rand(10,15)
fig = plt.figure(figsize=(16,10))
ax = fig.gca(projection='3d')
surf = ax.plot_surface(x, y, z, cmap=cm.jet)
axes = plt.gca()
fig.tight_layout()
plt.show()
Now, if I set axis limits, I have a problem
r1 = np.arange(10)
r2 = np.arange(15)
x, y = np.meshgrid(r2,r1)
z = np.random.rand(10,15)
fig = plt.figure(figsize=(16,10))
ax = fig.gca(projection='3d')
surf = ax.plot_surface(x, y, z, cmap=cm.jet)
axes = plt.gca()
axes.set_xlim([r1[2],r1[8]])
axes.set_ylim([r2[2],r2[8]])
fig.tight_layout()
plt.show()
gives:
What I was expecting was it to cut the original fig in the limits I asked, without putting the plot outside the box. How do I do that?

