python - different linestyle/marker for each line in my 20 lines line plot
问题描述
I`m trying to have a different linestyle or marker for each line in my plot to have the plot more visually appealing to me, I tried to give different colors using (hsv) but the colors are still close to each other which prevent me to differentiate between the lines, here is my code:
plt.figure(figsize=(15,15))
import matplotlib.colors as colors
i=1
for cluster_index in [0,1,2]:
plt.subplot(3,1,cluster_index + 1)
for index, row in data_consumption2.iterrows():
if row.iloc[-1] == cluster_index:
hsv = ((1/25)*i, 0.2+ (i%2)/2,.8)
plt.plot(row.iloc[1:-1] , color =colors.hsv_to_rgb(hsv) ,marker='v', alpha=1)
i+=1
plt.legend(loc="best")
plt.plot(kmeans.cluster_centers_[cluster_index], color='k' ,marker='o', alpha=1)
plt.xticks(rotation='vertical')
plt.ylabel('Electricity Consumption')
plt.title(f'Cluster {cluster_index}', fontsize=20)
plt.tight_layout()
plt.show()
I`ve 25 different lines in the second cluster and I hope if anyone can give me tips to change the linestyle in each iteration of the for loop
解决方案
推荐阅读
- java - 如何解决 Jsoup Java 中的 HTML 错误 500
- mysql - 如何在 MYSQL 列中保存数据更改
- html - 如何让我的页脚响应而不会出现故障?
- html - bootstrap3 中的内联日期选择器
- c# - WPF 中的 Application.OpenForms[0].InvokeRequired 等效项
- javascript - 如何通过 reactnavigation v5 将参数从一个屏幕传递到另一个屏幕
- javascript - `for/in` 循环包含奇怪的索引
- spring-boot - org.hibernate.boot.model.TypeContributor:未找到提供程序
- awk - 如何通过awk排除与列中正则表达式模式匹配的行?
- python - Python 帮助处理包和模块