I created a scatter plot using a dataframe that has 3 columns (x,y,z). I am now changing the scatter plot type to an Axes3D.scatter() so that it is 3D and can rotate. Axes3D.scatter() takes two position arguments, and I don't know how to convert my 3 data points into 2.
Axes3D.scatter(xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True, *args, **kwargs)
Creates a scatter plot.
Argument--> Description xs, ys --> Positions of data points. zs--> Either an array of the same length as xs and ys or a single value to place all points in the same plane. Default is 0.
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
Axes3D.scatter(finalDf.loc[indicesToKeep, 'principal component 1']
, finalDf.loc[indicesToKeep, 'principal component 2']
, finalDf.loc[indicesToKeep, 'principal component 3']
, c = colors
)
The error I get is:
AttributeError: 'Series' object has no attribute 'has_data'
I assume this is because the data I am giving for xs, yz is only one datapoint.
What I would like to see is a 3D scatter plot.