Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

Do an animation in 1 command in gnuplot

I'm trying to show an animation using gnuplot I got the following script:

plot   ”heat1d.txt ”  using   1:2   every   :::a::a 
pause   0.01
a=a+1
if ( a<b )   reread

that I execute using

a = 0
b = 100
load "a.plot"

it works, but is there a way to execute all of this using only 1 command from a shell? Alternatively is there a way to integrate the variable definitions into the .plot file so that I can simply execute it? I tried different things like echo 'a=0'|gnuplot etc but it doesn't seem to actually define the variable correctly

thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use a do for loop.

do for [a = 0:100] {
  plot   ”heat1d.txt ”  using   1:2   every   :::a::a 
  pause   0.01
}

The default terminal on linux is usually wxt, and it has the raise option, which will change the focus to the plot window at every iteration. This will make it difficult if not impossible to stop the animation.

I suggest to put noraise as the terminal option. For example, you can put the following line at the beginning of the script:

set term wxt noraise

Now, if you want to stop the animation halfway, press CtrlC on the gnuplot terminal.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...