0

I need to generate a graphic gnuplot using a bash script because I have multiple file to plot.

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

inside "Plot_Hisogramma.plt" i have

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

So I need a method to pass my index variable from the script to the gnuplot. I tried with echo, printf and export but maybe, I'm doing something wrong.

Arslan Ali
  • 17,418
  • 8
  • 58
  • 76
Ricky
  • 83
  • 5
  • It seems to me, that you want to see `MyFile[0].eps` etc. in "Plot_Hisogramma.plt". Is this really a filename? Seems to me a bit unusual, I have a little impression that you may speak about a variable from bash, that would look like `${MyFile[0]}` in bash. If this is not a case, forget it, just a comment... – jaromrax Apr 21 '15 at 09:05
  • That's normal. You can tell gnuplot to write to postscript, jpg, png, etc.. It is just setting the format for the output file (if other than the display) – David C. Rankin Apr 21 '15 at 09:12

1 Answers1

0

I think you may be misreferring the array:

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

And then the other script which I believe should be like this:

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

Also maybe this link helps: bash: loading presaved variable to gnuplot cmd load

Community
  • 1
  • 1
olopopo
  • 296
  • 1
  • 8