gnuplot中的自动系列? [英] Automatic series in gnuplot?

查看:66
本文介绍了gnuplot中的自动系列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我输入的内容如下:

year   s1   s2  s3
2000   1    2   3 
2001   2    4   6 
2002   4    8   12

我不知道有多少个系列.今天是3,明天可能是4.

I don't know how many series. Today it's 3, tomorrow it may be 4.

我想将其绘制在多系列图表中.像这样:

I want to plot it in a multi-series chart. Something like this:

set key autotitle columnhead
plot 'data/chart-year-subreddit-count' using 1:2 with lines, \
'data/chart-year-subreddit-count' using 1:3 with lines, \
'data/chart-year-subreddit-count' using 1:4 with lines

除了我不知道多少列之外,我不知道在gnuplot脚本中放什么.

Except since I don't know how many columns, I don't know what to put in my gnuplot script.

我必须编写脚本来写入文件吗?还是gnuplot可以自动计算出多少个序列?

Do I have to write a script to write the file? Or can gnuplot work out how many series there are automatically?

推荐答案

Gnuplot本身无法计算列数,但是您可以使用例如wchead计算列数:

Gnuplot itself cannot count the number of columns, but you can use e.g. wc and head to count the number of columns:

file = 'data/chart-year-subreddit-count'
cols = int(system('head -1 '.file.' | wc -w'))
plot for [i=2:cols] file using 1:i with lines

这篇关于gnuplot中的自动系列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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