如何在 gnuplot 中使用其中一列数据作为图例?

GP9*_*P92 5 gnuplot

我有这样的数据:

# c1 c2 c3
23 b 323
23 g 54
23 a 11
23 c 1
23 d 0
23 e 397
23 f 40
24 b 23
24 g 24
24 a 113
24 c 12
24 d 10
24 e 7
24 f 50
Run Code Online (Sandbox Code Playgroud)

我需要在 x 轴 (23,24) 上使用 c1,在 y 轴上使用 c3 来绘制不同的 c2 值,即每个 c2 值具有不同颜色的多个图表。

在此输入图像描述

Chr*_*oph 3

一般来说,您必须在 gnuplot 之外进行过滤,以便有连接过滤点的线。

如果您知道第二列中可能出现的所有值,则可以使用根据使用 gnuplot 的列值绘制多个图形中给出的解决方案。

如果您不知道可能的值,可以使用以下命令提取它们

c2s = system("awk '!/^#/ { print $2 }' test.dat | sort | uniq")
Run Code Online (Sandbox Code Playgroud)

然后用

plot for [c2 in c2s] sprintf('< grep ''\b%s\b'' test.dat', c2) using 1:3 with lines title c2
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述