Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
588 views
in Technique[技术] by (71.8m points)

awk - Gnuplot second from right or last coulmn


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

No need for awk. If you do stats you could limit it to one row with every ::0::0. It should be pretty fast. Try the following complete example:

Code:

### plotting columns from right
reset session

$Data <<EOD
11  21  31  41  51  61  71
12  22  32  42  52  62  72
13  23  33  43  53  63  73
14  24  34  44  54  64  74
15  25  35  45  55  65  75
16  26  36  46  56  66  76
17  27  37  47  57  67  77

EOD

stats $Data u 0 every ::0::0 nooutput
ColMax = STATS_columns

ColFromRight(col) = column(ColMax-col+1)

plot $Data u (ColFromRight(3)):(ColFromRight(4)) w lp pt 7
### end of code

Result:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...