着色3D散点图
我有一个绘制3D散点图的功能,它可以正常工作,但是我看不出如何根据条件为特定数据点给出颜色:
在以下代码中,我绘制了3个功能; NbactionsD30,AvgactionsMonth和Actionhr。
数据点给出特定的颜色
我想为actionshr值> = 50函数的参数为f1,f2,f3的 。数据是数据框 其中包含功能。
这是我函数的代码:
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
给出
gives