Gnuplot:如何跳过矩阵输入中的列以进行绘制? [英] Gnuplot: How do I skip columns in matrix input to plot?

查看:104
本文介绍了Gnuplot:如何跳过矩阵输入中的列以进行绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下格式的数据文件:

I have data file of the form:


unimportant1      unimportant2    unimportant3     matrixdata[i]
1e4               2e5             3e2              1 2 3 4 5
2e3               1e1             7e3              5 4 3 2 1
...               ...             ...              ...
2e3               1e4             4e2              4 4 4 4 4

因此,它的第一行具有列标题(此处为"unimportant1"至"unimportant3").我希望gnuplot忽略前三个不重要的列,因此数据条目采用指数表示法.我希望gnuplot将matrixdata绘制为矩阵.好像我是这样做的:

So it has columnheaders (here "unimportant1" to "unimportant3") as the first row. I want gnuplot to ignore these first three unimportant columns columns so the data entries in exponential notation. I want gnuplot to plot the matrixdata as a matrix. So as if I did it like this:

#!/usr/bin/gnuplot -p

plot '-' matrix with image
1 2 3 4 5
5 4 3 2 1
...
4 4 4 4 4

e

如何让gnuplot忽略前三列和标题行,并将其余部分绘制为矩阵图像?为了兼容,我希望使用内置的gnuplot来做到这一点,但是我可以编写一个shell脚本并使用`plot'< ..."语法对数据文件进行预处理.

How do I get gnuplot to ignore the first three columns and the header row and plot the rest as matrix image? For compatibility, I would prefere a gnuplot built-in to do that, but I could write a shell script and use the `plot '< ...' syntax preprocessing the data file.

编辑: neuhaus'

So neuhaus' answer almost solved it. The only thing I'm missing is, how to ignore the first row (line) with the text header data. Every seems to expect numeric data and so the whole plot fails as it's not a matrix. I don't want to comment out the fist line, as I'm using the unimportant data sets for other 2D plots that, in turn, use the header data.

那我如何跳过已经使用every 跳过列的矩阵图中的一行?

So how do I skip a row in a matrix plot that already uses every to skip columns?

推荐答案

使用matrix时,gnuplot必须首先解析数据文件,然后才能跳过行和列.现在,您的第一行的计算结果为四个无效数字,第二行的计算结果为8个数字,我得到一个错误Matrix does not represent a grid.

When using matrix gnuplot must first parse the data file before it can skip rows and columns. Now, your first row evaluates to four invalid number, the second row has 8 number and I get an error that Matrix does not represent a grid.

如果您不想注释掉第一行或不想使用< tail -n +2 matrix.dat这样的外部工具跳过它,则可以将其更改为包含一些虚拟字符串,例如

If you don't want to comment out the first line or skip it with an external tool like < tail -n +2 matrix.dat, then you could change it to contain some dummy strings like

unimportant1      unimportant2    unimportant3     matrixdata[i] B C D E
1e4               2e5             3e2              1 2 3 4 5
2e3               1e1             7e3              5 4 3 2 1
...               ...             ...              ...
2e3               1e4             4e2              4 4 4 4 4

现在第一行的条目与其他行一样多,您可以使用

Now your first row has as many entries as the other rows, and you can plot this file with

plot 'test.txt' matrix every ::3:1 with image

这仍然会为您提供warning: matrix contains missing or undefined values,但您无需在意.

This still gives you a warning: matrix contains missing or undefined values, but you don't need to care.

这篇关于Gnuplot:如何跳过矩阵输入中的列以进行绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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