Main /
MakingAnimationsMaking animations with XMGRACEXmgrace is pretty easy to script. Construct a text file that contains the commands you want common for all frames of the animation. This should set the axes, the line styles and colors, the plot title and so on. For example, TITLE "My example animation" WORLD XMIN 1 WORLD XMAX 32 WORLD YMIN 0.2 WORLD YMAX 1.2 XAXIS TICK MAJOR 10 XAXIS TICK MINOR 1 YAXIS TICK MAJOR 0.2 YAXIS TICK MINOR 0.1 s0 LINE LINEWIDTH 2.0 Save this as a file, say for i in dataset.t* ; do gracebat $i -batch setup.batch -printfile fig-$i.png -hdevice PNG -hardcopy ; done Now we use convert -delay 50 fig-*.png animation.gif Most likely, the convert -delay 50 $(cat files) animation.gif The usual output of the time evolution program produces files that do not appear in the proper sorting order. eg, time t=10 would be listed before time t=2, for example. One way to produce a sorted list is to specify the location of the key to the $ ls -1 density.t1 density.t10 density.t5 $ ls | sort -k 1.10 -n density.t1 density.t5 density.t10 The What we want to do now is set the title of the graph to Firstly, we set the title font to a fixed-width font. Remove the TITLE line from the setup.batch, and replace it with TITLE FONT "Courier" Now, our one-liner for generating the figures from the data is
An example output is at http://web.physik.rwth-aachen.de/~ianmcc/hubbard-animation-test.gif, that was produced with this scheme. This is the charge density profile of a single-particle excitation added to the left-most site at t=0. **WARNING: this is an almost 2MB .gif file. Making a movie from a sequence of framesThis is a simple script to generate a movie from a sequence of png images. here, #!/bin/bash # list pictures that we want to encode, in order. Assumed to be stored in file "pics" pics=$(cat pics) # picture type, png, jpeg etc type=png # output file name file_out=movie.avi # frames per second fps=20 # average bitrate in Mbps. Default is 6, but for a line animation we want much more obr=600 # options for the encoding: # keyint: insert a keyframe every n frames. This increases the size of the file, # but seeking is only possible to a key frame. Since we probably have a fairly # low framerate, this could be pretty small opt="keyint=25" # video codec. mpeg4 should be pretty safe codec="msmpeg4v2" # do it mencoder -ovc lavc -lavcopts vcodec=$codec:vbitrate=$obr:$opt -nosound -mf fps=$fps:type=$type -o $file_out $(for i in $pics ; do echo mf://$i ; done) A more complicated example that was generated with this script is http://web.physik.rwth-aachen.de/~ianmcc/hubbard-sc.avi Making animations with GNUPlotSomeone else will have to add this, I've never used GNUPlot much. |