如何在gnuplot中将数据列之一用作图例? [英] How to use one of the column of data as legend in gnuplot?

查看:156
本文介绍了如何在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

对于不同的c2值,我需要在x轴(23,24)上绘制c1,在y轴上绘制c3,即对于c2的每个值,绘制具有不同颜色的多个图形.

I need to plot with c1 on x-axis (23,24), c3 on y-axis for different values of c2 i.e, multiple graphs with different colors for each value of c2.

推荐答案

通常,您必须在gnuplot之外进行过滤,以使线连接过滤点.

In general, you must do the filtering outside of gnuplot, in order to have lines connecting the filtered points.

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

If you know all values which can appear in the second column, you can use the solution given in Plotting multiple graphs depending on column value with gnuplot.

如果您不知道可能的值,则可以使用

If you don't know the possible values, you can extract them with

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

然后用

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

这篇关于如何在gnuplot中将数据列之一用作图例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆