Gnuplot shell script controlled animation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Gnuplot shell script controlled animation
# 1  
Old 01-08-2009
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.

Darius
# 2  
Old 01-08-2009
Quote:
Originally Posted by darius2
I am looking for basic shell script to feed Gnuplot with live data, to arrange basic animation.

What data do you want to feed to gnuplot?

How does gnuplot accept its data? Command line? Standard input? File?
Quote:
I mean one-liner one variable real function.

Why a one-liner?
# 3  
Old 01-09-2009
Quote:
Originally Posted by cfajohnson

What data do you want to feed to gnuplot?

How does gnuplot accept its data? Command line? Standard input? File?

Why a one-liner?
Dear Mr. Johnson,

thank you very much for your kind reply.

I have played with gnuplot in the night and here are my basic results.

Having learned loop syntax for code refresh in gnuplot
load "loop3.plt"

loop3.plt code
==========
a = a + 1
f(x) = (x*x+a)

plot f(x)

if(a<5) reread


===========
init terminal strings

[admin@oo local]$ gnuplot

G N U P L O T
Version 4.2 patchlevel 4
last modified Sep 2008
System: Linux 2.4.20

Copyright (C) 1986 - 1993, 1998, 2004, 2007, 2008
Thomas Williams, Colin Kelley and many others

Type `help` to access the on-line reference manual.
The gnuplot FAQ is available from gnuplot: FAQ

Send bug reports and suggestions to <http://sourceforge.net/projects/gnuplot>


Terminal type set to 'unknown'
gnuplot> set terminal dumb
Terminal type set to 'dumb'
Options are 'feed 79 24'
gnuplot> a=-5
gnuplot> load "loop3.plt"

(I get series of slides generated)

110 ++---------------+-----------------+----------------+---------------++
* + + + f(x) ****** *
100 +* *+
| * * |
90 ++ * * ++
80 ++ * * ++
| ** ** |
70 ++ * * ++
| ** ** |
60 ++ ** ** ++
| * * |
50 ++ ** ** ++
| * * |
40 ++ ** ** ++
| ** ** |
30 ++ *** *** ++
20 ++ ** ** ++
| *** *** |
10 ++ ***** ***** ++
+ + ************ + +
0 ++---------------+-----------------+----------------+---------------++
-10 -5 0 5 10

gnuplot>

========
Modified code to
a = a + 1
f(x) = (x*x+a)
plot f(x)
clear
if(a<5) reread

but still a series of slides is generated.
Expected to clear screen before next slide is sent to terminal.

Ok.
So the above example is my first test in basic gnuplot animation on ASCII dumb terminal.

============
In the meantime I visited
your Shell Scripting Recipes
reading sample chapter
and testing your

split_date "DATE" [VAR1 [VAR2 [VAR3]]]

saved script code as splitdate, chmod 777 ./splitdate
and try to run it
[admin@oo root]$ ./splitdate "1949-09-29"
[admin@oo root]$ printf "$format" "$SD_DAY" "$SD_MONTH" "$SD_YEAR"
Day:
Month:
Year:
[admin@oo root]$

Could you kindly tell me how to make it working ?

I copy&pasted it into nano editor
appended
#!/bin/sh
and saved into root directory
chmod 777 ./splitdate

How to make it run
$ splitdate
instead of
$ ./splitdate ?

==================
split_date()
{
## Assign defaults when no variable names are given on the command line
sd_1=${2:-SD_YEAR}
sd_2=${3:-SD_MONTH}
sd_3=${4:-SD_DAY}

oldIFS=$IFS ## save current value of field separator
IFS="-/. $TAB$NL" ## new value allows date to be supplied in other formats
set -- $1 ## place the date into the positional parameters
IFS=$oldIFS ## restore IFS
[ $# -lt 3 ] && return 1 ## The date must have 3 fields

## Remove leading zeroes and assign to variables
eval "$sd_1=\"${1#0}\" $sd_2=\"${2#0}\" $sd_3=\"${3#0}\""
}


your Shell Scripting Recipes:


8: The Dating Game
example chapter.

I am just learning basics of Unix shell scripting
and moving from MS Vista to Linux environment is really hard.


From Vista laptop I putty Linux embedded device
and get access to ASCII dumb terminal.

I copy example script code c&p from Firefox MS Vista window
open nano script_name application
paste the code
append
#!/bin/sh

save, close, exit nano
chmod 777 ./script_name
and try to run script in another terminal session.

So to test and edit 10-20 example scripts takes me the whole night.

Are you aware of another option to test example shell script from the net on-the-fly ?
In Firefox I can run javascript / php scripts
Mayby I can use Lynx.
Unfortunately example shell script code doesn't come
as html code to be downloaded for immediate execution.

I installed basic http server.
Mayby I could save example shell scripts to local http server
and run them locally.

Any idea ?

file.plt is another scripting language I have to master,
so I am looking for a working test
of how to pipe Unix shell script output into
gnuplot > plot "< shellscript"

Tried in the night really hard and failed.

Darius
# 4  
Old 01-09-2009
follow-up

=======
as you can see from the referenced materials,
clear should clear a window or a screen
Unfortunately.
What I get using clear is still a tape with plotted frames


Darius



the issue is plot, screen clear and multiplot
Info: (gnuplot) clear

Info: (gnuplot) multiplot
Introductory Graphing

(gnuplot) multiplot


2.19.37 multiplot
-----------------

The command multiplot places `gnuplot` in the multiplot mode,
in which several plots are placed on the same page, window, or screen.

Syntax:
set multiplot
unset multiplot

For some terminals, no plot is displayed until the command
multiplot
is given, which causes the entire page to be drawn and then
returns `gnuplot` to its normal single-plot mode. For other terminals,
each separate `plot` command produces a plot, but the screen may not be
cleared between plots.

(gnuplot) clear

2.3 clear
=========

The clear command erases the current screen or output device as
specified by output. This usually generates a formfeed on
hardcopy devices. Use Image terminal to set the device type.

For some terminals Image clear erases only the portion of the
plotting surface defined by Image size, so for these it can be used
in conjunction with Image multiplot to create an inset.

Example:
set multiplot
plot sin(x)
set origin 0.5,0.5
set size 0.4,0.4
clear
plot cos(x)
unset multiplot

Please see Image multiplot, Image size, and Image origin for
details of these commands.
# 5  
Old 01-09-2009
here is what i have tried with gnuplot:

i have used the system function in C as follows:
Code:
 system("gnuplot.exe gnu_script");

you have to include the stdlib.h file.
this function calls the gnuplot.exe file and then runs the plots for gnuplot from the gnu_script file. The gnu_script file has gnu plot commands like:

Code:
plot "try.dat" using 1 with lines
pause -1 "Press enter for next plot"
plot "try1.dat" using 2 with lines
pause -1 "Press enter for next plot"
plot "try2.dat" using 1 with lines 
pause -1 "Press enter for next plot"

dunno if this may help. just an idea.
# 6  
Old 01-09-2009
Quote:
Originally Posted by npatwardhan
here is what i have tried with gnuplot:

i have used the system function in C as follows:
Code:
 system("gnuplot.exe gnu_script");

you have to include the stdlib.h file.
this function calls the gnuplot.exe file and then runs the plots for gnuplot from the gnu_script file. The gnu_script file has gnu plot commands like:

Code:
plot "try.dat" using 1 with lines
pause -1 "Press enter for next plot"
plot "try1.dat" using 2 with lines
pause -1 "Press enter for next plot"
plot "try2.dat" using 1 with lines 
pause -1 "Press enter for next plot"

dunno if this may help. just an idea.
Thanks.
In the meantime tested file.plt
run as any another shell script with plot commands
and it worked.

One issue is interaction and parameters entering for interaction and animation.
plot "-" command doesn't work withing .plt script

====================
./loop3.plt

plot "-"
^
"./loop3.plt", line 5: Bad data on line 1

======================
does work as
gnuplot > plot "-"
======================
4.9 Can I put both commands and data into a single file?

This is possible by the new plot "-" possibility. The plot "-" command allows to read the data to be plot from standard input or the current batch job.

gnuplot> plot "-"
1 1
2 4
3 9
e
# 7  
Old 01-10-2009
Quote:
Originally Posted by darius2
Thanks.
In the meantime tested file.plt
run as any another shell script with plot commands
and it worked.

One issue is interaction and parameters entering for interaction and animation.
plot "-" command doesn't work withing .plt script

====================
./loop3.plt

plot "-"
^
"./loop3.plt", line 5: Bad data on line 1

======================
does work as
gnuplot > plot "-"
======================
4.9 Can I put both commands and data into a single file?

This is possible by the new plot "-" possibility. The plot "-" command allows to read the data to be plot from standard input or the current batch job.

gnuplot> plot "-"
1 1
2 4
3 9
e
follow-up 2
=====================

What Wikipedia says for BATCH JOB
"
Batch processing is execution of a series of programs ("jobs") on a computer without human interaction.
Batch jobs are set up so they can be run to completion without human interaction, so all input data is preselected through scripts or command-line parameters. This is in contrast to "online" or interactive programs which prompt the user for such input. A program takes a set of data files as input,process the data,and produces a set of output data files.This operating environment is termed as "Batch Processing" because the input data are collected into Batches on files and are processed in Batches by the program.
"
Ok my friends.
So finally.


1.Gnuplot can read off-line data from datafile.dat,


2. Plot script can made of plot commands and run as shell script,


3. data input can be generated on-the-fly by another program/script

as batch job, and shell escape command is just -
plot "-" ... any data ... "e"

4. Plot file.plt can be generated on-the-fly by another program/script
as batch job
my question is, if commands in batch job script should be like
echo "plot "-""
echo "set terminal dumb"
or
print "plot "-""
print "set terminal dumb"

or look quite different to generate plot file file.plt ?

So, as you can see.
One good example can give answers to all of my questions.

Example of plot script generated by another program/script as batch job,
reading data input generated by one another program/script +
terminal, interactive data input like
plot "-"
any data
"e" to close data input from a command line.

===============
Neo administrator, in another Makefile generated by a script... thread
asked me, why my questions are so hard to understand for people
"
Thank you for your post, it is a bit hard for people to understand you. Could you be very specific about how we can help you, one question at a time? Thanks.
"

Frankly speaking, what I am looking for, is a problem solution.
What Neo suggested is to ask very basic questions, one question at a time.
I am sure, many experienced Shell scripters can answer either basic or more problem-oriented specific questions.

As I said above, one good Gnuplot plot example showing all the features I mentioned I exactly what I am looking for.

Neo asked me to make my problem-oriented specific questions as a series of very basic specific questions.
I really don't know what is an idea of flooding a forum with a number of questions if one problem-oriented specific question (REQUEST FOR EXAMPLE) is all I am looking for.

I can assure Neo, to ask more questions in a future.
Tonight, I have to solve very basic problem and learn how to use Gnuplot.

And I can assure you, that my Gnuplot problem-oriented specific question (request) is not really complicated for an experienced user of Gnuplot.

As a beginner to Gnuplot I have asked very very basic question.

Request for information, HowTo, HowItWorks, reference web sites
is in no way any violation of Unix forum standing rules, guidelines or standards.

What's more, at some Unix forums, people asking questions are requested to exactly ask one problem-oriented specific question not to flood a forum with a number of very basic questions, generating many threads.

Gnuplot plot is just another scripting language.
That's all.
And it makes no sense to spend a week, a month on mastering some Gnuplot related stuff if one good example is all I am looking for.

Already spent 2 nights visiting many Gnuplot devoted web sites.
So please don't tell me that my request is a complicated one.

I am asking just for one good example, nothing more and some discussion with experienced Gnuplot plot scripter.

Happy New Year
greetings,

Darius
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Gnuplot script

Need assistance in getting a script right. It requires little tweaking and I am not getting it right . Using below data and the below script it creates a table with png file but regarding the time it create 6,7,8 and i want each time 6:15 ,6:30 and so on So that i can view the exact graph... (3 Replies)
Discussion started by: ajayram_arya
3 Replies

2. 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

3. Solaris

In cluster configuration ora* VGs are not controlled by VCS

Need some one to explain "In cluster configuration ora* VGs are not controlled by VCS". Actually, I am not aware of this. Thanks, Rama (0 Replies)
Discussion started by: ramareddi16
0 Replies

4. Shell Programming and Scripting

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. #!/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... (5 Replies)
Discussion started by: Dark2Bright
5 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. Shell Programming and Scripting

Controlled For Loop

I have a for loop and i pass in number of times i want to loop as argument to script. I have attached a snippet of my script. Problem is this does not work, if I manually replace the $NO_OF_LOOPS with a number in the script it works fine. NO_OF_LOOPS=$1 for i in {0..$NO_OF_LOOPS} ... (8 Replies)
Discussion started by: kelseyh
8 Replies

7. Shell Programming and Scripting

Shell Script Animation

Hi, I want to write a shell script which can do some animation The animation is as follows it is like a progress barwhich hould gone on inresing with time & at the end of the line there should be the progess Eg == - 10%... (2 Replies)
Discussion started by: wojtyla
2 Replies

8. UNIX for Dummies Questions & Answers

script animation

I have read hundreds of the postings and cannot find the answer to my question...so I hope that someone is able to answer it for me. I am writing a script in bash, and would like to add animation. I have a gif file that I would like to open and have displayed on the screen. Can this be done? Of... (0 Replies)
Discussion started by: debit
0 Replies

9. Filesystems, Disks and Memory

IDE controlled / RAID card issue Suse 9.2

I just built a new box to run Suse, and I guess I shoud have spent more time researching the HCL. Anyway, the Promise RAID card I have will not work, and I am unable to install the OS. The only other IDE devide in the box is a DVDOM. I can only think of 2 options, but would appreciate some... (1 Reply)
Discussion started by: 98_1LE
1 Replies

10. UNIX Desktop Questions & Answers

3d animation

What are the benefits to using UNIX for 3d animation. I am looking into the field, and most places require a strong background in UNIX. Why is this? (3 Replies)
Discussion started by: aloysius1001
3 Replies
Login or Register to Ask a Question