在gnuplot的plot命令中进行计算 [英] Doing calculations in gnuplot's plot command

查看:50
本文介绍了在gnuplot的plot命令中进行计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下gnuplot代码效果很好:

The following gnuplot code works good:

plot 'data.txt'  using 2:4  '   %lf %lf %lf %lf' title "1 PE" with linespoints;

在下面的代码中,我想说:使用第4列中的数字,然后将其除以第3列中的数字".或:使用第2列中的数字,但将其除以常数2.0".下面的代码演示了我试图实现的目标,但是没有用.

In the following code, I want to say: "Use the number from column 4, but then divide it by the number from column 3". Or: "Use the number from column 2, but divide it by the constant 2.0". The following code demonstrates what I try to achieve, but it does not work.

plot 'data.txt'  using 2:4/4  '   %lf %lf %lf %lf' title "1 PE" with linespoints;
plot 'data.txt'  using 2:4/2.0  '   %lf %lf %lf %lf' title "1 PE" with linespoints;

这样可能吗?

推荐答案

我通常不使用这种格式的数据文件,但是我认为您正在寻找类似的东西:

I don't usually work with datafiles formatted like this, but I think you're looking for something like:

#divide column 4 by column 3
plot 'data.txt'  using 2:($4/$3)  '   %lf %lf %lf %lf' title "1 PE" with linespoints

#divide column 4 by constant 10.0
plot 'data.txt'  using 2:($4/10.0)  '   %lf %lf %lf %lf' title "1 PE" with linespoints

作为旁注,我认为没有任何理由将格式部分传递给此处使用.Gnuplot在空白处分割数据文件就好了:

As a side note, I don't think there's any reason for passing the format portion to using here. Gnuplot splits the datafile on whitespace just fine:

plot 'data.txt'  using 2:($4/$3) title "1 PE" with linespoints

应该可以正常工作.

这篇关于在gnuplot的plot命令中进行计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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