set term gif animate {delay <d>} {loop <n>} {{no}optimize}}
The gif terminal animate option creates a single gif file containing multiple frames. The delay between display of successive frames may be specified in units of 1/100 second (default 5), but this value may or may not be honored accurately by a program used to view the animation later. The number of animation loops during playback can be specified, with the default of 0 meaning unlimited looping. Again this value may or may not be honored by the program later used for viewing. An animation sequence is terminated by the next set output or set term command.
The optimize option [DEPRECATED] is passed to the gd library when the output file is opened. It has two effects on the animation.
1) A single color map is used for the entire animation. This requires that all colors used in any frame of the animation are already defined in the first frame.
2) If possible, only the portions of a frame that differ from the previous frame are stored in the animation file. This space saving may not be possible if the animation uses transparency.
Both of these optimizations are intended to produce a smaller output file, but the decrease in size is probably only significant for long animations. Caveat: The implementation of optimization in libgd is known to be buggy. Therefore use of this option in gnuplot is not recommended.
Example showing continuous rotation:
set term gif animate loop 0 set output 'rotating_surface.gif' do for [ang=1:359] { set view 60, ang splot f(x,y) with pm3d } unset output