Using variables in gnuplot within a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using variables in gnuplot within a shell script
# 1  
Old 10-21-2010
Using variables in gnuplot within a shell script

Hi everybody, please help me with this problem
Suppose I have a script like this to run commands of gnuplot.
Code:
#!/bin/sh
lib=$1
old="output/old/$lib.dat"
new="output/new/$lib.dat"

gnuplot << EOF
set logscale x
set logscale y
set size square
set grid
set pointsize 1
plot "< paste $old $new" using 1:4 ti '$lib'
EOF

Since I use logscale, some of my data which have value zero can not be displayed. So I want to write a simple function f(x) that, if the value is 0.000, I will change it to 0.001. Then I use the function on "using f($1):f($4)".
But I am afraid that the variable showing column $1 and $4 will be confused with the 1st and 4th variables of the shell script. Please tell me how I can deal with this problem.

Thank you very much.
# 2  
Old 10-24-2010
Before you start tampering data, could I ask you whether the results you want to display are actually in that domain? Or rather, is the core of your result in the regions where x >> 0, so that you could for instance plot the graph for x > 1?
# 3  
Old 10-24-2010
I am sorry, I deleted some parts of the script to make it simple. I want to display data in the range of [0.001..1000] for both x and y.
I want to write a function like this : f(x) = (x == 0) ? 0.001 : x , then apply for both x and y, i.e. column 1 and 4.
My problem is I can not use $1 and $4 to stand for columns, since it will be confused with the variables of shell script. Please help me.
# 4  
Old 11-19-2010
If you are still stuck on this, you need to use the back slash. f(\$1):f(\$4)
This User Gave Thanks to annazpereira For This Post:
# 5  
Old 11-19-2010
When in doubt, replace gnuplot with cat to make sure your plotting script is what you think it is.
This User Gave Thanks to Corona688 For This Post:
# 6  
Old 11-20-2010
Quote:
Originally Posted by annazpereira
If you are still stuck on this, you need to use the back slash. f(\$1):f(\$4)
Yes, my problem still remains. I will try with your instruction. Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

Pass shell variable to gnuplot

Hi I am plotting a series of CDFs using gnuplot using plot "data" u 1:(1./x.) smooth cumulative I am doing this over many files and I need to tune the x value to the number of lines that meets a particular condition. Is it possible to get the line count from shell using cat file | grep... (7 Replies)
Discussion started by: jamie_123
7 Replies

5. Shell Programming and Scripting

Passing gnuplot variables to shell script

Hi, I need to pass a gnuplot value to a shell script. I have a main shell script (Main.sh) that has a bunch of gnuplot commands. Main.sh calls another gnuplot script (Child.gnu). A part of the code in Child.gnu is as follows: sp '</data/src/scripts/results/plot_data.sh $col' u (A):2:3 w pm3d... (8 Replies)
Discussion started by: annazpereira
8 Replies

6. HP-UX

Shell script variables

hi everyone, i'm writing shell script on hp-ux server that run by root user then (inside the script) su to database user and appl user..the reason for this script is to run some commands involve all users root and database and appl..anyway, variables when root in control is ok but when su, the... (1 Reply)
Discussion started by: neemoze
1 Replies

7. Shell Programming and Scripting

Variables in shell script

mysqldump --compact --add-drop-table -h192.168.150.80 -uroot -p somePass $combined | sed '/$combined/$table/g' | mysql $databaseThe sed part is not working from the above statement. The variables combined and table are already defined and instead of showing the actual variable, it is executing the... (4 Replies)
Discussion started by: shantanuo
4 Replies

8. Shell Programming and Scripting

Accessing variables of one shell script in another shell script

Hi All, I have a shell script called sample1.sh where I have 2 variables. Now I have another shell script called sample2.sh. I want the variables in sample1.sh to be available to sample2.sh. For example. In sample1.sh I am finding the sum of 2 numbers namely a and b. Now I want to access... (2 Replies)
Discussion started by: rsendhilmani
2 Replies

9. Shell Programming and Scripting

Gnuplot shell script controlled animation

Hi, I am looking for basic shell script to feed Gnuplot with live data, to arrange basic animation. I mean one-liner one variable real function. Any idea or experiences from the past, generating Gnuplot animation on dumb terminal (ASCII only) ? Or please refer me to a nice web site. ... (7 Replies)
Discussion started by: darius2
7 Replies

10. Shell Programming and Scripting

Accessing variables of one shell script in another shell script

I have a variable $exe in a shell script file a.sh which I need to access in another shell script file b.sh. How can I do that? :rolleyes: Thanks!! (2 Replies)
Discussion started by: looza
2 Replies
Login or Register to Ask a Question