【问题标题】:gnuplot plot the curves in filegnuplot 在文件中绘制曲线
【发布时间】:2013-12-22 08:19:29
【问题描述】:

我有一个要绘制的表格文件,文件中的每一列对应一条曲线

例如,file1

N plot1 plot2 plot3

1 2     3     4
2 3     4     5

我按如下方式运行 gnuplot

gnuplot -e "set key autotitle columnhead; set title 'file1'; plot 'file1' using 1:2 with lines, 'file1' using 1:3 with lines, 'file1' using 1:4 with lines"

问题是如果我有很多曲线要绘制,我有很多列我需要在命令中为 gnuplot 描述它们,但是我认为用第一列绘制每个列文件是非常标准的,比如 @ 987654323@

我能否以更方便的方式进行操作,而不列出所有列?

【问题讨论】:

    标签: function graph plot gnuplot curves


    【解决方案1】:

    这可以使用 forloop 来完成,例如

    plot for [i=2:4] "file" using 1:i
    

    您需要至少 4.4 的 Gnuplot 版本才能使用此功能。

    【讨论】:

    • 非常感谢您的回答,您是否知道如何使是通用的,例如如果我的曲线少于4条或多于4条?
    • @user16168 我真的不知道该怎么做。
    • 您需要一个外部工具来计算列数。试试MAXCOL = int(system('head -1 '.file.' | awk "{print NF}"'))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多