gnuplot:在Y轴上绘制一个4列的文件 [英] gnuplot: plotting a file with 4 columns all on y-axis

查看:138
本文介绍了gnuplot:在Y轴上绘制一个4列的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含4个数字(最小,最大,均值,标准导数)的文件,我想用gnuplot对其进行绘制。

I have a file that contains 4 numbers (min, max, mean, standard derivation) and I would like to plot it with gnuplot.

样本:

24 31 29.0909 2.57451
12 31 27.2727 5.24129
14 31 26.1818 5.04197
22 31 27.7273 3.13603
22 31 28.1818 2.88627

如果我有4个文件的一栏,那么我可以:

If I have 4 files with one column, then I can do:

gnuplot "file1.txt" with lines, "file2.txt" with lines, "file3.txt" with lines, "file4.txt" with lines



,它将绘制4条曲线。我不在乎x轴,它应该只是一个恒定的增量。

And it will plot 4 curves. I do not care about the x-axis, it should just be a constant increment.

我该如何绘制?我似乎无法找到一种方法来使4条曲线与1个文件包含4列,只是x值不断增加。

How could I please plot? I can't seem to find a way to have 4 curves with 1 file with 4 columns, just having a constantly incrementing x value.

谢谢。

推荐答案

您可以像这样绘制同一文件的不同列:

You can plot different columns of the same file like this:

plot 'file' using 0:1 with lines, '' using 0:2 with lines ...

... 表示继续)。关于此符号的几点注释: using 指定要绘制的列,即第一个 using 语句中的列0和1 ,第0列是伪列,它转换为数据文件中的当前行号。请注意,如果只有一个参数与使用一起使用(例如,使用n ),则相当于说使用0:n (感谢指出 mgilson )。

(... means continuation). A couple of notes on this notation: using specifies which column to plot i.e. column 0 and 1 in the first using statement, the 0th column is a pseudo column that translates to the current line number in the data file. Note that if only one argument is used with using (e.g. using n) it corresponds to saying using 0:n (thanks for pointing that out mgilson).

如果您的Gnuplot版本足够新,则可以使用for循环绘制所有4列:

If your Gnuplot version is recent enough, you would be able to plot all 4 columns with a for-loop:

set key outside
plot for [col=1:4] 'file' using 0:col with lines

结果:

如果它们在数据文件中,则Gnuplot可以使用列标题作为标题,例如:

Gnuplot can use column headings for the title if they are in the data file, e.g.:

min max mean std
24 31 29.0909 2.57451
12 31 27.2727 5.24129
14 31 26.1818 5.04197
22 31 27.7273 3.13603
22 31 28.1818 2.88627

set key outside
plot for [col=1:4] 'file' using 0:col with lines title columnheader

结果是

这篇关于gnuplot:在Y轴上绘制一个4列的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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