本文介绍了在gnuplot上绘制10行sof 1000值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个10行的数据文件,每行1000个值,我正在尝试使用此脚本绘制这些值

I have a data file with 10 lines with 1000 values each line and I'm trying to plot this values with this script

#!/usr/bin/gnuplot -persist

 plot "data.dat" using [1:1000] title "" with lines

但我收到此错误

plot "data.dat" using [1:1000] title "" with lines
                      ^
"./plot.sh", line 3: invalid expression 

如何将第一个值的间隔指定为1000个值?无法为每行设置不同的随机值?

How can I indiate a interval form the first value to the 1000 value?I't posible to set a diferent random clor to every line?

推荐答案

正如@vaettchen指出的那样,gnuplot希望将数据放在列中,而绘制行并不容易.因此,最好是如果您的数据已转置.不幸的是,gnuplot没有功能来转置数据.因此,您必须使用外部工具来转置数据.

As @vaettchen pointed out, gnuplot wants data in columns and plotting rows is not straightforward. So, best would be if your data was transposed. Unfortunately, gnuplot has no function to transpose data. So, you have to use external tools to transpose your data.

尽管,如果您的数据是10行,每行有1000个值,即严格的10x1000矩阵,则只能使用gnuplot进行操作(请参见下文).但是,如果您的数据不是严格的矩阵,例如一行包含更多或更少的值,或者缺少以下方法的一个值将不起作用.

Although, if your data is 10 lines with 1000 values each, i.e. a strict 10x1000 matrix, you could do something with gnuplot only (see below).However, if your data is not a strict matrix, e.g. one line has more or less values or one value missing the method below won't work.

以下示例(仅5行,每行7个值)说明了绘制列和绘制行.

The following example (just 5 lines with 7 values each) illustrates plotting columns and plotting rows.

### plotting columns and rows
reset session
set colorsequence classic

$Data <<EOD
11  12  13  14  15  16  17
21  22  23  24  25  26  27
31  32  33  34  35  36  37
41  42  43  44  45  46  47
51  52  53  54  55  56  57
EOD

# get the number of rows
stats $Data u 0 nooutput
RowCount = STATS_records

# do the plot
set multiplot layout 1,2
    set title "Plotting columns"
    set xlabel "Row no."
    set xtics 1
    # plot all columns from 1 to *(=autodetection)
    plot for [i=1:*] $Data u ($0+1):i w lp pt 7 not

    set title "Plotting rows"
    set xlabel "Column no."
    # plot all rows
    plot for [i=0:RowCount-1] $Data matrix u ($1+1):0 every :::i::i w lp pt 7 not
unset multiplot
### end of code

这将导致:

这篇关于在gnuplot上绘制10行sof 1000值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 18:17