Search code examples
animationgnuplotgifanimated-gifantialiasing

How can I use antialiasing in Gnuplot to make an gif?


For example, What do I need to add to this code to activate the antialiasing?

set terminal gif animate delay 5 size 400, 250
set output "example.gif"

a = 0

do for [i=1:100] {
a = a + 0.1
plot sin(x + a)
}

example.gif

Do I need to change some of the files of the gnuplot folder? I'm using the 5.2 Windows version of gnuplot.


Solution

  • Use the terminal pngcairo that has antialiasing to create separate png files:

    set terminal pngcairo size 400, 250
    
    a = 0
    
    do for [i=1:100] {
    set output sprintf("%.3d.png",i)
    plot sin(x + a)
    a = a + 0.1
    }
    

    Then you can assemble a gif file, for example, with ImageMagick's convert:

    convert -delay 5 -loop 0 *.png animation.gif
    

    enter image description here