【问题标题】:Gnuplot through bash script [duplicate]Gnuplot通过bash脚本[重复]
【发布时间】:2015-04-21 08:14:52
【问题描述】:

我需要使用 bash 脚本生成图形 gnuplot,因为我要绘制多个文件。

while [ $j -lt 30 ]; 
  do
    if [ -f ./MyFile[$j] ]; then 
    load 'Plot_Histogramma.plt'
    fi
j=$(( $j + 1 ))
done

在“Plot_Hisogramma.plt”里面我有

set output "MyFile[$j].eps"
plot "./MyFile[$j]" using 2:1 title "MyTitle" with boxes ls 7 lc rgb "blue"

所以我需要一种方法将我的索引变量从脚本传递到 gnuplot。我尝试使用echoprintf 和导出,但也许我做错了什么。

【问题讨论】:

  • 在我看来,您想在“Plot_Hisogramma.plt”中看到MyFile[0].eps 等。这真的是文件名吗?在我看来有点不寻常,我有一点印象,你可能会谈论 bash 中的一个变量,它看起来像 bash 中的${MyFile[0]}。如果不是这种情况,算了,只是评论...
  • 这很正常。您可以告诉 gnuplot 写入 postscript、jpg、png 等。它只是设置输出文件的格式(如果不是显示)

标签: linux bash shell gnuplot


【解决方案1】:

我认为您可能误用了数组:

while [ $j -lt 30 ]; do
    if [ -f ./${MyFile[$j]} ]; then 
    load 'Plot_Histogramma.plt'
    fi
j=$(( $j + 1 ))
done

然后我认为另一个脚本应该是这样的:

set output "${MyFile[$j]}.eps"
plot "./${MyFile[$j]}" using 2:1 title "MyTitle" with boxes ls 7 lc rgb "blue"

也许这个链接有帮助:bash: loading presaved variable to gnuplot cmd load

【讨论】:

    猜你喜欢
    • 2012-10-29
    • 1970-01-01
    • 1970-01-01
    • 2017-08-04
    • 1970-01-01
    • 2022-01-20
    • 2021-12-30
    • 2020-04-02
    • 2011-06-04
    相关资源
    最近更新 更多