如何在Gnuplot的一个文件中绘制多个带有标题的数据集? [英] How to plot several datasets with titles from one file in Gnuplot?

查看:70
本文介绍了如何在Gnuplot的一个文件中绘制多个带有标题的数据集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个看起来像这样的文件:

Assuming I have a file that looks like this:

"p = 0.1"
1 1
3 3
4 1


"p = 0.2"
1 3
2 2
5 2

是否可以使Gnuplot将这两个数据集绘制在一个图中,并在每个数据集的第一行给出标题?

Is it possible to make Gnuplot plot these two datasets in one plot with the titles given on the first line of each dataset?

推荐答案

这绝对有可能,并且您的数据文件已经是正确的格式.您要查找的功能内置于columnheader(N)中,该功能读取第N列顶部的数据并将其用作绘图标题:

It's definitely possible and your datafile is already the correct format. The functionality you're looking for is built into columnheader(N) which reads the data at the top of the N'th column and uses it as the plot title:

 plot 'test.dat' i 0 u 1:2 w lines title columnheader(1),\
      'test.dat' i 1 u 1:2 w lines title columnheader(1)

可以使用迭代压缩:

plot for [IDX=0:1] 'test.dat' i IDX u 1:2 w lines title columnheader(1)

这篇关于如何在Gnuplot的一个文件中绘制多个带有标题的数据集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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