【发布时间】:2021-10-27 18:13:34
【问题描述】:
我是下面的数据框,我有唯一的compIds,它可以有多个capei 和多个date。这主要是一个时间序列数据集。
date capei compId
0 200401 25.123777 31946.0
1 200401 15.844910 29586.0
2 200401 20.524131 32507.0
3 200401 15.844910 29586.0
4 200401 15.844910 29586.0
... ... ... ...
73226 202011 9.372320 2817.0
73227 202011 9.372320 2817.0
73228 202011 22.334842 28581.0
73229 202011 10.761727 31946.0
73230 202011 30.205348 15029.0
使用以下可视化代码,我得到了图,但线图的颜色没有什么不同。我想要不同的颜色。
import seaborn as sns
a4_dims = (15, 5)
sns.set_palette("vlag")
**plot**
sns.set_style('ticks')
fig, ax = plt.subplots()
fig.set_size_inches(11.7, 8.27)
sns.relplot(x="date", ax=ax, y="capei", style='compId', kind='line',data=fDf, palette=sns.color_palette("Spectral", as_cmap=True) )
它会生成这样的图像
但是我期待情节像这样
图片生成图1中的compId可以相当于图2中的月份。 图2是here的截图。
如何在图 1 中为 compId 设置不同的颜色。
【问题讨论】:
标签: python pandas matplotlib plot seaborn