I'm working with 2-D matrices, where the entries are elevation, and am trying to plot them with MatPlotLib mplot3d. How can I adjust the vertical height of the resulting figure? To give an example, pulling from code in the mplot3d tutorial:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
# Make data.
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)
# Plot the surface.
surf = ax.plot_surface(X, Y, Z, linewidth=0, antialiased=False)
# Configure z-axis.
ax.set_zlim(-1.01, 1.01)
plt.show()
This gives:
I'd like to compress the picture vertically so that the 1.00
mark on the z-axis gets pushed down to present position of -0.75
.
Changing the z-limit with ax.set_zlim(-1.01, 10.01)
flattens the data but keeps the figure the same height. I've also experimented with statements like plt.figure(figsize=(20,5))
, but that changes the figure size and interferes with rotating the resulting plot in 3-D.
How do I compress down just the z-axis?