0

I am learning this tutorial. In cell [13], it has the following code:

from mpl_toolkits import mplot3d

def plot_3D(elev=30, azim=30, X=X, y=y):
    ax = plt.subplot(projection='3d')
    ax.scatter3D(X[:, 0], X[:, 1], r, c=y, s=50, cmap='autumn')
    ax.view_init(elev=elev, azim=azim)
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('r')

interact(plot_3D, elev=[-90, 90], azip=(-180, 180),
         X=fixed(X), y=fixed(y));

If I change the call to interact with direct call to plot_3D, I get a nice three-dimensional chart:

enter image description here

With interact, however, I get the following:

enter image description here

How do I fix this?

AlwaysLearning
  • 7,257
  • 4
  • 33
  • 68

1 Answers1

0

elev = 90 means view the plot from the top, so it looks like 2D, just adjust elev will have a 3D plot back. I am using elev=(-180, 180), rather than elev=[-90, 90] so can adjust the elev more freely

Shabari nath k
  • 920
  • 1
  • 10
  • 23
Aaron
  • 1
  • 1