LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 08-17-2012, 04:25 AM   #1
sbgirl54
LQ Newbie
 
Registered: Aug 2012
Location: France
Posts: 6

Rep: Reputation: Disabled
Red face 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?

Last edited by sbgirl54; 08-17-2012 at 04:26 AM. Reason: some of my code was interpretted as smileys. :?
 
Old 08-17-2012, 06:01 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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.
 
Old 08-17-2012, 07:02 AM   #3
sbgirl54
LQ Newbie
 
Registered: Aug 2012
Location: France
Posts: 6

Original Poster
Rep: Reputation: Disabled
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
 
Old 08-17-2012, 07:18 PM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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.
 
Old 08-20-2012, 10:18 AM   #5
sbgirl54
LQ Newbie
 
Registered: Aug 2012
Location: France
Posts: 6

Original Poster
Rep: Reputation: Disabled
That clarifies many things. Thanks a lot (:
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a path to a gnuplot script from bash script mystupidquestion Programming 2 10-11-2011 09:10 AM
[SOLVED] issue with gnuplot script Simon_6162 Linux - Software 4 07-08-2011 06:40 AM
gnuplot script gav251 Linux - Software 2 02-24-2010 05:42 AM
Imbedded video interndan Slackware 7 09-23-2009 04:59 PM
Cannot View Imbedded Video in Browser bmorgan8 Linux - Newbie 3 02-27-2007 09:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration