【发布时间】:2017-05-07 08:45:42
【问题描述】:
我有一个以下格式的熊猫数据框。我正在尝试根据 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()
【问题讨论】:
-
你认为完美的结果是什么?