【问题标题】:Replot not working on gnuplot重新绘制不适用于 gnuplot
【发布时间】:2016-09-19 19:15:08
【问题描述】:

我想在单个图像中绘制不同的线条。每一行都保存在一个不同的纯文本文件中,它有: x |是 |深度。因此,我编写了这个名为 'plot_vg' 的文件:

set term pngcairo size 1000,8005

list = system('ls')
i = 1

set output 'image.png'

do for [file in list] {
if (file ne 'image.png') {
   if (file ne 'plot_vg') {
       if (file ne '..') {
         if (i==1) {
           i=0
           plot sprintf('%s',file) using 1:2:3 with lines notitle
         } else{
           replot sprintf('%s',file) using 1:2:3 with lines notitle
         }
       }
    }
}
}

我的问题是,最后,保存的图像只是最后一次重新绘制的图像,不包括其余的行。我已经看到它很好地进入了循环,它做了 1 个绘图,然后,其余的都是重新绘图。如果我从术语中打开 gnuplot 并编写前 1 个绘图然后重新绘图,则显示的图像就是我想要的。哪里出错了?

我从这里Gnuplot - Using replot with png terminal 尝试了第一个选项,但我得到一个空白图像文件。

【问题讨论】:

    标签: loops gnuplot


    【解决方案1】:

    在读取文件列表时已经进行过滤,然后使用plot for [file in list]...进行迭代:

    set term pngcairo size 1000,8005
    
    list = system("ls | grep -v 'image.png\|plot_vg'")
    
    set output 'image.png'
    
    set style data lines
    unset key
    plot for [file in list] file using 1:2
    

    如果您的数据文件遵循某种模式,您也可以使用类似

    list = system("ls *.txt")
    

    另请注意,简单的plot with lines 仅使用两列。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多