Gnuplotting

Create scientific plots using gnuplot

August 17th, 2012 | 2 Comments

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

Fig. 1 Video animation of head related impulse responses (HRIRs) (code to produce this figure, data)

In comparison to the additional file for the loop in Animation I – gif, now all we need is this small code block.

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
    [...]
}

2 Comments

  1. Xenofon Floros says:

    Can I ask a stupid question? I have the following problem.. I have a csv file with 2 columns with x (time) and y values of a trajectory.. I need to animate the trajectory as it evolves over time.. So in each frame i I suppose I have to plot all values until i and some marker in the end to denote the current position.. How can I adapt your code to do that? I cannot get it to work..

    Thanks a lot,

  2. hagen says:

    Great question, I have created an extra entry to answer it: http://www.gnuplotting.org/animation-iv-trajectory/

Leave a Reply