我有一个以下格式的熊猫数据框。我试图绘制基于ClusterAssigned这个数据,可能与不同颜色的0和1熊猫数据框中的值散点图
Distance ClusterAssigned
23 1
35 1
20 1
264 0
830 0
我想这个代码,但似乎并没有得到完美的结果。
groups = dfprintscatter.groupby('ClusterAssigned')
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.margins(0.05)
for name, group in groups:
ax.plot(group.Distance, group.ClusterAssigned, marker='o', linestyle='', ms=5, label=name)
ax.legend()
plt.show()
你怎么认为完美的结果? – piRSquared