Search code examples
gnuplotgif

gnuplot command not valid


I am trying to create a gif of the movement of two circular objets. Below is my choc.gnu file, where data_choc.txt contains four columns of the object's positions. When typing in load "choc.gnu", it says that line 12 is an invalid command. Any ideas why? Thanks a lot!

reset
set datafile separator "  "
set terminal gif animate delay 1
set output 'choc.gif'
set xrange [-0.1:1.7]
set yrange [-0.3:1.05]
set size ratio -1

do for [ii=1:300] {
    plot 'data_choc.txt' u 1:2 every ::1::ii w l lt rgb "red", 
    '' u 1:2:(0.051111) every ::ii::ii w circle lt rgb "red", 
    '' u 3:4 every ::1::ii w l lt rgb "blue", 
    '' u 3:4:(0.05) every ::ii::ii w circle lt rgb "blue"
}

Solution

  • In order to continue a command across multiple lines, you must end the partial lines with a trailing \ character. So

    do for [ii=1:300] {
        plot 'data_choc.txt' u 1:2 every ::1::ii w l lt rgb "red", \
        '' u 1:2:(0.051111) every ::ii::ii w circle lt rgb "red", \
        '' u 3:4 every ::1::ii w l lt rgb "blue", \
        '' u 3:4:(0.05) every ::ii::ii w circle lt rgb "blue"
    }