如何在gnuplot标题中包含目录名称的详细信息?

时间:2014-08-29 14:28:40

标签: bash gnuplot

如何在gnuplot的标题中包含目录名称的详细信息?目前,我的gnuplot脚本是:

set multiplot title "Pressure Convergence Plots"

但我希望标题说:'压力收敛图用于溢出率1和网格细化0',其中'Q1_GR0'是目录名称,'1'和'0'是跟随'Q'的数字'和'GR'在目录名称中。

如果无法做到这一点,标题是否可以说:'Q1_GR0的压力收敛图',其中'Q1_GR0'是目录名?

我正在使用gnuplot版本4.6

谢谢。

2 个答案:

答案 0 :(得分:1)

这可以使用bash命令完成。我喜欢它非常复杂:

rate = "`pwd | rev | cut -f 1 -d '/' | rev | cut -f 2 -d 'Q' | cut -f 1 -d '_'`"
refinement = "`pwd | rev | cut -f 1 -d '/' | rev | cut -f 2 -d 'R'`"
fulltitle = 'Pressure Convergence Plots for overflow rate '.rate.' and grid refinement '.refinement
set multiplot title fulltitle

答案 1 :(得分:1)

这取决于您拥有的sed版本,但这对我有用:

rep = sprintf("Pressure Convergence Plots for overflow rate \\1 and grid refinement \\2")
t = system(sprintf("sed -r 's/SF[0-9]+_Q([0-9]+)_GR([0-9]+)/%s/' <<<${PWD##*/}", rep))
set multiplot title t

sed命令捕获Q和GR之后的数字,并在替换字符串中使用它们。我已经使用sprintf将命令分成两行。

相关问题