Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

animations with gnuplot

163 views
Skip to first unread message

Mauro Copelli

unread,
Jun 29, 2000, 3:00:00 AM6/29/00
to

Hi,

I'm trying to create animated 2-D plots with gnuplot, and so
far the only way I came up with was the following: for each
"time frame" my Fortran code adds the following to an output
file, say, animation.gplt:

-------------------------------------
set title "t = 0"
plot '-' using 2:4 w histeps

[ 4 columns of points generated by the program,
corresponding to t = 0]

e
pause -1
-------------------------------------

and the above is repeated for subsequent times. It works
beautifully. But...

The problem is that I might need to further process those
data in the future, or I might decide to plot something
else, like the data from this file together with data from
another file, for instance. In short, even though the script
works nicely, the data is now "contaminated" by gnuplot
commands.

Is there a way out of this trade off? Do you guys know of
any way I could put just the data in one file, and then
write a gnuplot script file that would do the same job as my
example above?

Any help would be greatly appreciated!

--
Mauro Copelli


Dmitri Volfson

unread,
Jun 30, 2000, 3:00:00 AM6/30/00
to
Mauro Copelli wrote:
>
> Hi,
>
> I'm trying to create animated 2-D plots with gnuplot, and so
> far the only way I came up with was the following: for each
> "time frame" my Fortran code adds the following to an output
> file, say, animation.gplt:
>
> -------------------------------------
> set title "t = 0"
> plot '-' using 2:4 w histeps
>
> [ 4 columns of points generated by the program,
> corresponding to t = 0]
>
> e
> pause -1
> -------------------------------------
...

> In short, even though the script
> works nicely, the data is now "contaminated" by gnuplot
> commands.

Mauro -

you may want to use sed to postprocess your file 'animation.gplt'.
for example, you may comment all gnuplot commands with

sed -e 's/^[a-z]/#&/' animation.gplt > animation.dat

(to uncomment then:
sed -e 's/#//' steps1.dat
)

if you need to extract a specific frame, say at t = 2, use
sed -e '/=\ 2/,/pause/\!d' animation.gplt > frame.2

and so on...

Dmitri Volfson

Mauro Copelli

unread,
Jun 30, 2000, 3:00:00 AM6/30/00
to

On Fri, 30 Jun 2000, Dmitri Volfson wrote:

> you may want to use sed to postprocess your file 'animation.gplt'.
> for example, you may comment all gnuplot commands with
>
> sed -e 's/^[a-z]/#&/' animation.gplt > animation.dat
>
> (to uncomment then:
> sed -e 's/#//' steps1.dat
> )
>
> if you need to extract a specific frame, say at t = 2, use
> sed -e '/=\ 2/,/pause/\!d' animation.gplt > frame.2

Thank you for the hint! Actually I found another way to do it. I can
create a data file (only with data) organized as follows:

# block 0
323 1234 123 12
123 12 1234 213
.
. the line below is blank
. vvvvvvv

# block 1
323 1234 123 12
123 12 1234 213
.
.
.

etc.

Then you can create an animation by using the "every" option:

plot 'datafile' every :::0::0 using 2:4 w histeps
pause -1
plot 'datafile' every :::1::1 using 2:4 w histeps
pause -1

etc.

My problems right now lie in having a Fortran program create a gnuplot
script with the right syntax (Fortran is horrible for handling
strings), so I'm considering learning C just for this small
task. Actually I had thought of using the "call" command in gnuplot,
and then giving the data file as argument. Is it possible to have a
file name filled by the call option? Suppose I have a script like

# begin whatever.gplt
plot $1 w l
# end whatever.gplt

Can I then make something like

gnuplot> call "whatever.gplt" "'datafile.dat'"

??

Thanks again,

--
Mauro Copelli


0 new messages