gnuplot图的2列差异 [英] gnuplot plot difference of 2 columns

查看:75
本文介绍了gnuplot图的2列差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文件A和B.两个文件都包含2列,即x和y.

I have two files A and B. Both files contain 2 columns, x and y.

现在,我想绘制x与(yA-yB)的关系图. gnuplot是否提供相同的命令?

Now, I want to plot a graph for x vs (yA - yB). Does gnuplot provide a command for the same ?

还有一件事,假设xA和xB不相同.我应该如何绘制一个图形,其中x轴包含xA和xB都包含的所有元素,而y轴是对应的y分量的区别?

One more thing, lets say xA and xB are not same. How should I plot a graph where x-axis contains all elements which are in both, xA and xB and y-axis is the difference is the corresponding y-components ?

推荐答案

首先,在bash中使用join预处理文件:

First, preprocess the files with join in bash:

join <(sort -k1,1 file1) <(sort -k1,1 file2) > file3

对文件进行排序是必不可少的,否则join将不起作用.

Sorting the files is essential, otherwise join would not work.

然后您可以使用结果绘制图形:

Then you can use the result to draw the graph:

plot '< sort -n file3' using 1:($2-$3) with lines

再次,这里需要数字排序,因为join使用字母数字排序,使行彼此交叉.

Again, numeric sorting is needed here, because join uses alphanumeric sorting which makes the lines cross each other.

这篇关于gnuplot图的2列差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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