首页 > 解决方案 > 以不同的形状绘制第一个点

问题描述

我正在通过以下方式进行集群可视化:

for k in range(0, n_clusters):
    x=[]
    y=[]
    for j in range(0, len(final_cluster_result[k])):
        x_res = list(final_cluster_result[k][j].longitude)
        y_res = list(final_cluster_result[k][j].latitude)
        x.append(x_res)
        y.append(y_res)
    x = [s for t in x for s in t]
    y = [s for t in y for s in t]
    plt.plot(x,y,'o',markersize=3)
#     plt.scatter(x,y)
    plt.grid()
    plt.title('Clusters',fontsize=14)
    plt.xlabel("Longitude",fontsize=15)
    plt.ylabel("Latitude",fontsize=15)

我想以不同的形状绘制集群/颜色的每个起点(以了解运动从哪里开始)

样本图

我想要:对于蓝色绘图的第一个点,带有蓝色的黑点对于 rescolor 绘图的第一个点,带有红色的黑点...

标签: pythonpandasmatplotlib

解决方案


同意@Quang-Hoang,在这里粘贴以供其他人过滤没有答案的问题:

在 plt.plot(x,y,'o',markersize=3) 之后做 plt.plot([x[0]], [y[0]], 's', markersize=5)


推荐阅读