I am not sure about how to rotate graph in Python Jupyter notebook, its static for me and not rotate on mouse movement
from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x =[1,2,3,4,5,6,7,8,9,10] y =[5,6,2,3,13,4,1,2,4,8] z =[2,3,3,3,5,7,9,11,9,10] ax.scatter(x, y, z, c='r', marker='o') ax.set_xlabel('X Label') ax.set_ylabel('Y Label') ax.set_zlabel('Z Label') plt.show()
Use the Rotate3D tool on the toolbar to enable and disable rotate3D mode on a plot, or select Rotate 3D from the figure's Tools menu.
To generate an interactive 3D plot first import the necessary packages and create a random dataset. Now using Axes3D(figure) function from the mplot3d library we can generate a required plot directly. Pass the data to the 3D plot and configure the title and labels.
Generally 3D scatter plot is created by using ax. scatter3D() the function of the matplotlib library which accepts a data sets of X, Y and Z to create the plot while the rest of the attributes of the function are the same as that of two dimensional scatter plot.
To enable interactivity you need to use the notebook
backend of matplotlib. You can do this by running %matplotlib notebook
.
This must be done before you plot anything, e.g.:
%matplotlib notebook import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d fig = ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With