【问题标题】:Figure with clusters of different color in pythonpython中不同颜色的簇的图
【发布时间】:2021-10-22 03:28:32
【问题描述】:

我有一个有 6 列的数据框。最重要的是“经度”、“纬度”和“id_cluster”。

我希望为每个 id_clusters 绘制每个点 X、Y。图中总共有 7 个簇必须是不同颜色的

我有这个代码:

train = pd.read_excel(r"C:\Users\Jonat\Downloads\denstream-master\denstream-master\output\beijing.xlsx")
fig = plt.figure(figsize=(9, 6))
plt.plot(train['longitud'], train['latitud'], ".b", markersize=15)

这是我的数据框:

enter image description here

我想要这样的东西:

enter image description here

【问题讨论】:

  • 请不要发布您的数据集的图像,尝试将它们添加为代码。

标签: python plot cluster-analysis


【解决方案1】:

您可以使用 Seaborn 软件包轻松创建集群的散点图和根据集群的色点。

import seaborn as sns

sns.scatterplot(data=train, x="longitude", y="latitude", hue="id_cluster")

【讨论】:

  • 谢谢。另一方面,你知道有什么图书馆可以帮助我用分组轨迹绘制地图吗?
  • @ServicesPuzzlesConsulting 您可能需要为此创建一个新问题
猜你喜欢
  • 1970-01-01
  • 2015-03-29
  • 2016-11-04
  • 2021-12-08
  • 2011-10-12
  • 2020-06-04
  • 1970-01-01
  • 2015-10-07
  • 2019-03-08
相关资源
最近更新 更多