Canvas Gnuplot:在绘图画布之间切换

Canvas Gnuplot:在绘图画布之间切换,canvas,gnuplot,Canvas,Gnuplot,我有一个包含不同数量级列的数据文件。我想将所有具有相似数量级的列一起绘制到同一画布中。为此,我使用stats命令测试每列的最大值 我已经试过了 set key autotitle columnheader set terminal pdfcairo set out 'test.pdf' do for [col=5:125] { stats 'datafile' using col nooutput if( STATS_max < 1e-7 ) { #draw to c

我有一个包含不同数量级列的数据文件。我想将所有具有相似数量级的列一起绘制到同一画布中。为此,我使用
stats
命令测试每列的最大值

我已经试过了

set key autotitle columnheader
set terminal pdfcairo
set out 'test.pdf'

do for [col=5:125]  {
  stats 'datafile' using col nooutput
  if( STATS_max < 1e-7 ) { 
    #draw to canvas 1
    plot 'datafile' using 1:col with lines
  } else {
    if( STATS_max < 1e-6 ) {
      #draw to canvas 2
      plot 'datafile' using 1:col with lines
    } else {
      #draw to canvas 3
      plot 'datafile' using 1:col with lines
    }
  }
}
是否有办法实现这种行为,如果有,如何实现?
提前感谢。

您可以先将相应的列号组合成单独的变量,然后在脚本的最后绘制所有内容。例如,使用
test.dat
作为:

1   10  11  100 101 1000    1001
2   20  21  200 201 2000    2001
3   30  31  300 301 3000    3001
4   40  41  400 401 4000    4001
5   50  51  500 501 5000    5001
下面的脚本仅绘制“第一组”,即第2列和第3列:

fName = 'test.dat'

set terminal pngcairo
set out 'fig.png'

#max. column number in the datafile
N = 5

#inspired by https://stackoverflow.com/a/35729052/5351549
_group_1 = ""
_group_2 = ""
_group_3 = ""

groupAppend(idx, col) = sprintf("_group_%d = _group_%d . \" %d\";", idx, idx, col)

do for [col=2:N]  {
    stats fName using col nooutput
    if( STATS_max < 1e2 ) { 
        eval groupAppend(1, col)
    } else {
        if( STATS_max < 1e3 ) {
            eval groupAppend(2, col)
        } else {
            eval groupAppend(3, col)
        }
    }
}

plot for [i in _group_1] fName u 1:int(i) w l t sprintf("column %s", i)
fName='test.dat'
设置终端pngcairo
设置“fig.png”
#数据文件中的最大列数
N=5
#灵感来自https://stackoverflow.com/a/35729052/5351549
_组_1=“”
_组_2=“”
_组_3=“”
groupAppend(idx,col)=sprintf(“\u group\u%d=\u group\u%d.\%d\”,idx,idx,col)
do for[col=2:N]{
使用col nooutput的stats fName
如果(STATS_max<1e2){
eval groupAppend(1,列)
}否则{
如果(统计最大值<1e3){
评估组附加(2,列)
}否则{
eval groupAppend(第3列)
}
}
}
[i in _group_1]fName u 1的绘图:int(i)w l t sprintf(“列%s”,i)

对于较新版本的Gnuplot,可以使用数组来保存列索引,而不是以空格分隔的方式将它们存储为字符串的间接方法。

您可以首先将相应的列编号组合成单独的变量,然后在脚本的最后绘制所有内容。例如,使用
test.dat
作为:

1   10  11  100 101 1000    1001
2   20  21  200 201 2000    2001
3   30  31  300 301 3000    3001
4   40  41  400 401 4000    4001
5   50  51  500 501 5000    5001
下面的脚本仅绘制“第一组”,即第2列和第3列:

fName = 'test.dat'

set terminal pngcairo
set out 'fig.png'

#max. column number in the datafile
N = 5

#inspired by https://stackoverflow.com/a/35729052/5351549
_group_1 = ""
_group_2 = ""
_group_3 = ""

groupAppend(idx, col) = sprintf("_group_%d = _group_%d . \" %d\";", idx, idx, col)

do for [col=2:N]  {
    stats fName using col nooutput
    if( STATS_max < 1e2 ) { 
        eval groupAppend(1, col)
    } else {
        if( STATS_max < 1e3 ) {
            eval groupAppend(2, col)
        } else {
            eval groupAppend(3, col)
        }
    }
}

plot for [i in _group_1] fName u 1:int(i) w l t sprintf("column %s", i)
fName='test.dat'
设置终端pngcairo
设置“fig.png”
#数据文件中的最大列数
N=5
#灵感来自https://stackoverflow.com/a/35729052/5351549
_组_1=“”
_组_2=“”
_组_3=“”
groupAppend(idx,col)=sprintf(“\u group\u%d=\u group\u%d.\%d\”,idx,idx,col)
do for[col=2:N]{
使用col nooutput的stats fName
如果(STATS_max<1e2){
eval groupAppend(1,列)
}否则{
如果(统计最大值<1e3){
评估组附加(2,列)
}否则{
eval groupAppend(第3列)
}
}
}
[i in _group_1]fName u 1的绘图:int(i)w l t sprintf(“列%s”,i)

对于较新版本的Gnuplot,可以使用数组来保存列索引,而不是以空格分隔的方式将它们存储为字符串的间接方法。

非常有效。谢谢工作完美。谢谢