PKlumpp
PKlumpp

Reputation: 5233

Zoom out in Matplotlib

I have a surface plot, and I need this specific point of view that I have chosen. See the image below:

enter image description here

Now, as you can see, the very bottom part of my axis legend is missing, because matplotlib is cutting it off. Is there any way to programmatically zoom out of the plot so everything fits in the window?

This is my original code:

values_all = zip(*values_all)
x = range(len(values_all[0]))
y = range(len(values_all))
figure = plt.figure(1, figsize=(10, 7))
ax = Axes3D(figure, azim=-124, elev=40, zlim=(0, 0.4))
x, y = np.meshgrid(x, y)
surface = ax.plot_surface(x, y, values_all, linewidth=0, rstride=1, cstride=1, cmap=cm.jet)
plt.colorbar(surface, shrink=0.4, aspect=10)
plt.show()

Upvotes: 4

Views: 6704

Answers (1)

MaxNoe
MaxNoe

Reputation: 14987

Call

 plt.tight_layout()

before

 plt.show()

Upvotes: 5

Related Questions