0

in mplot3d how do I change my axis limits such gets cut off the at the limites. When using ax.set_xlim3d() the graph continuous out the plot. Consider the graph generated by:

import numpy as np; import matplotlib.pyplot as plt;
from mpl_toolkits import mplot3d

def func(x, y):
    return x ** 2 + 0.5*y ** 3


x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)

X, Y =np. meshgrid(x, y)
Z = func(X, Y)

plt.clf()
fig = plt.figure(1)
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z, rstride=2, cstride=1,
            cmap='viridis', edgecolor='none')

Say I want to cut my z = 50, so the last part disappears. ax.set_zlim3d(-100,50) doesn't do the trick. I have a lot of code written in this form so I prefer not to use the method described here mplot3D fill_between extends over axis limits where the core code of the plots are totally different than mine. TI figure there must be a way to fix my problem my adding a line of code to my existing code.

k.dkhk
  • 481
  • 1
  • 11
  • 24

0 Answers0