LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   imbedded gnuplot script problem (https://www.linuxquestions.org/questions/linux-software-2/imbedded-gnuplot-script-problem-4175422583/)

sbgirl54 08-17-2012 04:25 AM

imbedded gnuplot script problem
 
Hello all.

I have embedded a gnuplot script into a .sh by using

for i in *.spe
do
gnuplot << EOF
set title "File : $i "
set term png
set output "${i%.txt}.png"
plot [0:22000] 'final.res' u 1: (2*$i), '' u 1: (2*$i+1), '$i.spe' w l
unset output
set term wxt
EOF
done
exit 1

That obviously doesn't work (please don't laugh at me, I'm aware it can't) because $i is read as i.spe, not the number i.

Basically I have about 15000 stellar objets so 15000 graphs to plot. for each of them 1:2i from final.res and i.spe are 2 different theoretical models, and 1: (2i+1) are the observed values.

What is the proper way to achieve that?

evo2 08-17-2012 06:01 AM

Hi,

it's been a long time since I used gnuplot and I'm having a little trouble understanding exactly what you want to do. So, if you could post gnuplot commands that will work for a single file we should be able to show you how to fix the script to run over all your files.

Evo2.

sbgirl54 08-17-2012 07:02 AM

Ooops, sorry not clear.

to get only the 6th (say) graph printed to the file '6.png', I would write:

do
gnuplot << EOF
set title "File : $i "
set term png
set output "6.png"
plot [0:22000] 'final.res' u 1:12, '' u 1:13, '6.spe' w l
unset output
set term wxt
EOF
done

and for say the 7th graph, the middle lines would change to

set output "7.png"
plot [0:22000] 'final.res' u 1:14, '' u 1:15, '7.spe' w l


does that clarify? :s

evo2 08-17-2012 07:18 PM

Hi,

ok, I think I understand now. Please try something like the following
Code:

#!/bin/bash
for f in *.spe
do
    i=${f%\.spe}
    echo "i = $i"
    j=$((2*i))
    k=$((j+1))
gnuplot << EOF
set tit $f
set term png
set output \'${i}.png\'
plot [0:22000] \'final.res\' u 1:${j}, u 1:${k}, \'${f}\' w
unset output
set term wxt
EOF
done

Please note that some of my gnuplot syntax may be wrong, but I think that your column numbers should be ok.

HTH,

Evo2.

sbgirl54 08-20-2012 10:18 AM

That clarifies many things. Thanks a lot (:


All times are GMT -5. The time now is 10:22 PM.