Matplotlib - 3D Plotting
You want to create a 3D scatter plot and set the view so the plot looks rotated 45 degrees horizontally and tilted 30 degrees vertically. Which code snippet correctly achieves this and also labels the axes?
projection='3d', which is required for 3D plots.ax.view_init(30, 45) is correct. fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter([1,2,3], [4,5,6], [7,8,9])
ax.view_init(30, 45)
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
plt.show() matches this.set_xlabel, set_ylabel, and set_zlabel.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions