Python 聚类:如何改变图形的颜色

Python 聚类:如何改变图形的颜色,python,time-series,cluster-analysis,graph-visualization,Python,Time Series,Cluster Analysis,Graph Visualization,我编写了以下代码来可视化时间序列集群 for yi in range(6): plt.subplot(6, 1, 1 + yi) for xx in stack_data[y_pred6 == yi]: plt.plot(xx.ravel(), "k-", alpha=.2)e plt.tight_layout() plt.show() 我使用的数据是33维NumPy

我编写了以下代码来可视化时间序列集群

for yi in range(6):
            plt.subplot(6, 1, 1 + yi)
            for xx in stack_data[y_pred6 == yi]:
                plt.plot(xx.ravel(), "k-", alpha=.2)e
    
    plt.tight_layout()
    plt.show()

我使用的数据是33维NumPy数组,如下所示

In:stack_data.shape
out:(33, 3277, 1)
在每个图上,我想为前14个数组加上一个红色:也就是说,
stack\u data[0:13]
。 接下来的17个数组为蓝色:
stack\u data[14:32]

我们可能会在阵列上添加标签方面找到一些线索,但请告诉我您的想法。
谢谢。

您可以使用
ax=plt.subplot(6,1,1+yi)
然后通过
ax.plot(xx.ravel(),color=color,alpha=.2,linestyle='--')为线条赋予不同的颜色。