Gnuplot:从一个文件中绘制几个带有标题的数据集 [英] Gnuplot: Plotting several datasets with titles from one file

查看:263
本文介绍了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在一个图中绘制这两个数据集,并在每个数据集的第一行给出标题? / p>

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列顶部的数据,并将其用作绘图标题: p>

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天全站免登陆