简体   繁体   English

在 Matplotlib 图表/绘图中的不同行中添加不同的标记

[英]Adding Different Markers to Different Lines in Matplotlib Charts/Plots

I have a chart of the performance of different optimisations/C flags for the Intel-icc compiler with increasing system size.我有一张图表,显示了随着系统大小的增加,Intel-icc 编译器的不同优化/C 标志的性能。 There are 4 in total but it can be hard to see each one of them on the chart despite the different colours.总共有 4 个,但尽管颜色不同,但很难在图表上看到它们中的每一个。 The best way of distinguishing them will be to add a different marker to each line.区分它们的最佳方法是在每一行添加不同的标记。 However, this is where I'm stuck.但是,这就是我卡住的地方。 Although I can use 1 marker, therefore all lines will have the same marker;虽然我可以使用 1 个标记,但所有行都将具有相同的标记; not much use.没多大用处。

What works:什么有效:

import matplotlib.pyplot as plt

df.plot.line(marker = 'x')
plt.xlabel('System Size')
plt.ylabel('Updated Cells')

Thats fine.没关系。 在此处输入图像描述

So I guess the problem I've got is associating a different marker/symbol to each line.所以我想我遇到的问题是将不同的标记/符号与每一行相关联。

Any help/direction appreciated任何帮助/方向表示赞赏

You can just make a quick loop and plot each column separately:您可以分别制作一个快速循环和 plot 每列:

for m, col in zip('xosd', df):
    df[col].plot(marker=m)
    
plt.legend()

Output: Output:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM