bash 仅在 gnuplot 中绘制特定列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45802125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
plot only specific columns in gnuplot
提问by user2650277
I have a csv file as show below and i want to plot S(on x axis) and B(axis).How do i generate a plot of lines with gnuplot.
我有一个如下所示的 csv 文件,我想绘制 S(在 x 轴上)和 B(轴)。如何使用 gnuplot 生成线条图。
Test_Image,Original_Size
red-room.png,918394
Q,S,B,S,C,R
0,1021763,0.121086,0.00001459,-11.26,-222.18
1,1061763,0.125086,0.00001459,-11.26,-222.18
2,1051763,0.121086,0.00001459,-11.26,-222.18
3,1041763,0.121086,0.00001459,-11.26,-222.18
4,986461,0.151573,0.00003318,-7.63,-211.67
5,955766,0.160869,0.00005782,-4.07,-201.37
Basically i need to a way to tell gnuplot to ignore the first 3 rows and plot the 2rd and 3rd column.
基本上我需要一种方法来告诉 gnuplot 忽略前 3 行并绘制第 2 和第 3 列。
回答by user8153
You need to tell gnuplot that fields are delimited by commas and that it should plot columns 2 and 3:
您需要告诉 gnuplot 字段由逗号分隔,并且它应该绘制第 2 列和第 3 列:
set datafile separator comma
plot "data.csv" using 2:3 w lp
Gnuplot will ignore the first three lines automatically.
Gnuplot 会自动忽略前三行。
回答by Mark Setchell
You can modify the data as it is read in (without affecting your input file) like this:
您可以在读取数据时修改数据(不影响您的输入文件),如下所示:
plot 'awk -F, "NR>3{print ,}" data.csv |' using ...
That says to print fields 2 and 3 of lines where line number is greater than 3 of your input file data.csv
.
这表示要打印行号大于输入文件 3 的行的字段 2 和 3 data.csv
。
You can experiment with the awk
command stand-alone in the Terminal to test it outside of gnuplot
:
您可以awk
在终端中单独使用命令进行试验,以在以下情况下对其进行测试gnuplot
:
awk -F, 'NR>3{print , }' data.csv