Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
Last edited by sbgirl54; 08-17-2012 at 04:26 AM.
Reason: some of my code was interpretted as smileys. :?
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.