I have a function to plot 3D scatter plots, it works fine but I don't see how I can give a color to specific data points based on a condition for example:
in The following code I am plotting 3 features; nbActionsD30, avgActionsMonth and actionSHR.
I want to give a specific color to the data points where actionsSHR value >= 50
the parameters of the function are f1, f2, f3 the feature names. data is the dataframe that contains the features.
here is my function's code :
def plot3D(f1, f2, f3, data):
%matplotlib widget
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
xs = data[f1]
ys = data[f2]
zs = data[f3]
fig = plt.figure()
ax = Axes3D(fig)
plot = ax.scatter(xs, ys, zs, s=50, color = 'blue', edgecolors = "white")
ax.set_xlabel(f1)
ax.set_ylabel(f2)
ax.set_zlabel(f3)
plt.show()
plot3D("avgActionsMonth", "nbActionsD30", "actionSHR", data)