如何从gnuplot中的相同标准输入数据绘制多个图? [英] how to make several plots from the same standard input data in gnuplot?

查看:169
本文介绍了如何从gnuplot中的相同标准输入数据绘制多个图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个同时存储数据和gnuplot命令的.plt文件.我的数据看起来像

I want to have a single .plt file storing both data and gnuplot commands. My data looks like

# x1 y1 x2 y2
  1  2  3  4
  5  6  7  8

并对应于两个图:(x1,y1)和(x2,y2).

and corresponds to two plots: (x1,y1) and (x2,y2).

我知道我可以像这样使用"-":

I know I can use "-" like:

plot "-" using 1:2
# x1 y1 x2 y2
  1  2  3  4
  5  6  7  8
e

但这只会生成一个图,即(x1,y1).我正在尝试做类似的事情

But that would generate only one plot, i.e., (x1,y1). I'm trying to do something like

plot "-" using 1:2, "-" using 3:4
# x1 y1 x2 y2
  1  2  3  4
  5  6  7  8
e

但是显然这是行不通的,因为gnuplot希望从第二个"-"的标准输入中获得一组新的数据.

but obviously that doesn't work since gnuplot expects a new set of data from the standard input for the second "-".

注意:

  1. 我无法更改数据的样式.它分为四列.
  2. 看来我可以用reread做到这一点,但这需要两个文件.我真的只想要一个文件.
  1. I cannot change the style of the data. It comes in four columns.
  2. It seems that I can do it with reread but that requires two files. I really want only one file.

推荐答案

如果不对输入数据的方式进行一些修改,就无法做到这一点.通过标准输入馈送gnuplot数据时,它期望多个数据集之间用两条空行分隔,或在连续的行中交织.选项是:

You can't do this without modifying something about the way you input the data. When feeding gnuplot data via standard input, it expects multiple data sets to be delimited with two blank lines between them, or to be interleaved on successive lines. The options are:

  • 将两个数据集送入不同的位置 一起绘制命令.

  • Feed the two data sets into different plot commands altogether.

更改 文件格式,以便数据集具有 他们之间的空行,然后 用 index 引用它们.

Change the file format so that data sets have blank lines between them, then reference them all with index.

更改文件格式,以便 交替线代表不同 数据集,然后全部引用 与每个一起使用.

Change the file format so that alternating lines represent different data sets, then reference them all with every.

将数据放入一个 文件,将绘图脚本放入 另一个,然后引用数据 用不同的文件多次 每次使用子句.

Put the data into one file, the plotting script into another, and then reference the data file more than once with different using clauses each time.

每个 index 命令的介绍都从

There's an intro to the every and index commands starting at How do I plot several data sets in a single file? Those are the only facilities built into gnuplot for this sort of thing, and neither does exactly what you were asking about. it's good you've already modified the data formatting, because this wasn't ever going to work as you'd originally hoped.

这篇关于如何从gnuplot中的相同标准输入数据绘制多个图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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