<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gnuplotting &#187; animation</title>
	<atom:link href="http://www.gnuplotting.org/tag/animation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gnuplotting.org</link>
	<description>Create scientific plots using gnuplot</description>
	<lastBuildDate>Tue, 21 May 2013 13:43:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Animation III &#8211; video revisited</title>
		<link>http://www.gnuplotting.org/animation-iii-video-revisited/</link>
		<comments>http://www.gnuplotting.org/animation-iii-video-revisited/#comments</comments>
		<pubDate>Fri, 17 Aug 2012 10:00:31 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[do]]></category>
		<category><![CDATA[grid]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1494</guid>
		<description><![CDATA[As already mentioned gnuplot 4.6 overs an easier way to include loops in your code. Here we are using it to create an animation of a set of head related impulse responses, which show differences in amplitude and arrival time at the left and right ear of a listener depending on the position of the [...]]]></description>
				<content:encoded><![CDATA[<p>As <a href="http://www.gnuplotting.org/gnuplot-4-6-do/">already mentioned</a> gnuplot 4.6 overs an easier way to include loops in your code.<br />
Here we are using it to create an animation of a set of <a href="https://dev.qu.tu-berlin.de/projects/measurements/wiki/2010-11-kemar-anechoic">head related impulse responses</a>, which show differences in amplitude and arrival time at the left and right ear of a listener depending on the position of the source. </p>
<div class="figure">
  <video id="hrirs" controls loop><source src="http://www.gnuplotting.org/video/hrir.webm" type='video/webm; codecs="vorbis,vp8"' /><a href="http://www.gnuplotting.org/video/hrir.webm">Download the video</a></video>
<p class="caption">
  <strong>Fig. 1 </strong>Video animation of head related impulse responses (HRIRs) (<a href="http://www.gnuplotting.org/code/animate_ir.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/data/ir.txt">data</a>)
  </p>
</div>
<p>In comparison to the additional file for the loop in <a href="http://www.gnuplotting.org/animation-gif/">Animation I &#8211; gif</a>, now all we need is this small code block.</p>
<pre class="prettyprint">
do for [ii=1:181] {
    set output sprintf('hrir_frame%03.0f.png',ii)
    set multiplot layout 2,1
    [...]
    plot 'ir.txt' u ($1*1000):2*ii-1 w l ls 1
    [...]
    plot 'ir.txt' u ($1*1000):2*ii w l ls 1
    [...]
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/animation-iii-video-revisited/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://www.gnuplotting.org/video/hrir.webm" length="369452" type="video/webm" />
		</item>
		<item>
		<title>Animation II &#8211; video</title>
		<link>http://www.gnuplotting.org/animation-video/</link>
		<comments>http://www.gnuplotting.org/animation-video/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 13:25:37 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[reread]]></category>
		<category><![CDATA[system]]></category>

		<guid isPermaLink="false">http://www.gnuplotting.org/?p=1189</guid>
		<description><![CDATA[In the first post regarding animations we have created a bunch of png files and combined them to a single gif animation. Now we want to generate again a bunch of png files, but combine them to a movie. Download the video Fig. 1 Video animation of Huygens principle (code to produce this figure, loop [...]]]></description>
				<content:encoded><![CDATA[<p>In the <a href="http://www.gnuplotting.org/animation-gif/">first post regarding animations</a> we have created a bunch of png files and combined them to a single gif animation. Now we want to generate again a bunch of png files, but combine them to a movie.</p>
<div class="figure">
  <video id="huygens_principle" controls loop><source src="http://www.gnuplotting.org/video/huygen.webm" type='video/webm; codecs="vorbis,vp8"' /><a href="http://www.gnuplotting.org/video/huygen.webm">Download the video</a></video>
<p class="caption">
  <strong>Fig. 1 </strong>Video animation of Huygens principle (<a href="http://www.gnuplotting.org/code/huygen.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/code/huygen.plt">loop function</a>)
  </p>
</div>
<p>We create the png files in analogy to the gif example, hence we will discuss only the generation of the movie here. In order to compose a avi file from the png files we are using <a href="http://www.mplayerhq.hu">Mencoder</a>. Gnuplot is able to directly start Mencoder by its <code>system</code> command.</p>
<pre class="prettyprint">
# Create movie with mencoder
<span class="v">ENCODER</span> = system('which mencoder');
if (<span class="f">strlen</span>(<span class="v">ENCODER</span>)==0) print '=== mencoder not found ==='; exit
<span class="v">CMD</span> = 'mencoder mf://animation/*.png -mf fps=25:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o huygen.avi'
system(<span class="v">CMD</span>)
</pre>
<p>The first two lines check if Mencoder is available and quit gnuplot if not. The Mencoder command itselfs gets the directory containing the png files <code>mf://animation/*.png</code>, frames per second and input type<code>-mf fps=25:type=png</code>, video <code>-ovc</code> and audio <code>-oac</code> options, and finally of course the output file <code>-o huygen.avi</code>.</p>
<p>In order to generate a <a href="http://www.webmproject.org/">webm</a> video file for a web site, ffmpeg can be used to convert the video.</p>
<pre class="prettyprint">
<span class="pr">$</span> ffmpeg -i huygen.avi huygen.webm
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/animation-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.gnuplotting.org/video/huygen.webm" length="192914" type="video/webm" />
		</item>
		<item>
		<title>Animation I &#8211; gif</title>
		<link>http://www.gnuplotting.org/animation-gif/</link>
		<comments>http://www.gnuplotting.org/animation-gif/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 14:13:53 +0000</pubDate>
		<dc:creator>hagen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[bessel]]></category>
		<category><![CDATA[gif]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[reread]]></category>

		<guid isPermaLink="false">http://gnuplot.kkdu.org/?p=134</guid>
		<description><![CDATA[For presentation or teaching purposes it can be useful to show not only a figure, but an animation to illustrate something more clear. There exists different possibilities to do this in Gnuplot. Today we will have a look at how to create a gif animation. Fig. 1 Animation of Bessel function (code to produce this [...]]]></description>
				<content:encoded><![CDATA[<p>For presentation or teaching purposes it can be useful to show not only a figure, but an animation to illustrate something more clear. There exists different possibilities to do this in Gnuplot. Today we will have a look at how to create a gif animation.</p>
<div class="figure">
    <img src="http://www.gnuplotting.org/figs/bessel.gif" alt="Bessel function" width="350"/>
<p class="caption">
        <strong>Fig. 1 </strong>Animation of Bessel function (<a href="http://www.gnuplotting.org/code/bessel.gnu" type="text/plain">code to produce this figure</a>, <a href="http://www.gnuplotting.org/code/bessel.plt">loop</a>)
    </p>
</div>
<p>Fig. 1 shows a gif animation of a Bessel function of first kind and zeroth order. Gnuplot has a gif output <code>terminal</code>, but the result will be smoother if we first create png files with Gnuplot and then the animated gif file with another program. In order to create a set of png files we have to loop through the time value <code>t</code> and different output files.</p>
<pre class="prettyprint">
# initializing values for the loop and start the loop
<span class="v">t</span> = 0
<span class="v">end_time</span> = 1
system('mkdir -p animation')
load 'bessel.plt'
</pre>
<p>The above code sets a start value for the running time variable <code>t</code> and the <code>end_time</code> variable at which the looping should be stopped. Then a folder for the output png files is created and the loop file <code>bessel.plt</code> is loaded. The content of this loop file is shown below.</p>
<pre class="prettyprint">
# bessel loop
<span class="v">t</span> = <span class="v">t</span> + 0.02
<span class="v">outfile</span> = sprintf('animation/bessel%03.0f.png',50*<span class="v">t</span>)
set output <span class="v">outfile</span>
splot <span class="v">u</span>*<span class="f">sin</span>(<span class="v">v</span>),<span class="v">u</span>*<span class="f">cos</span>(<span class="v">v</span>),<span class="f">bessel</span>(<span class="v">u</span>,<span class="v">t</span>) w pm3d ls 1
if(<span class="v">t</span>&lt;<span class="v">end_time</span>) reread;
</pre>
<p>Here we update the time <code>t</code>, create a file name with a different number and plot out Bessel function. Finally the last line checks if our time <code>t</code> is smaller than the <code>end_time</code> variable, and executes the loop again if this is the case.</p>
<p>After we have created the png files in the animation folder, we start <a href="http://www.gimp.org" target="_blank">GIMP</a> and load all the files as layers (File > Open as Layers). After this we save all layers together as an animated gif file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gnuplotting.org/animation-gif/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
