f(x,t) = sin(w*t - k*x)
g(x,t) = sin(w*t + k*x)
w = 1; k = 1;
#
set style line 100 lw 2 lc "#ffffcc"
set style line 101 lw 2 lc "#00ff33"
set style line 102 lw 2 lc "#ff3300"

set samples 400
set noytics
set xtics nomirror tc "white"
set border 1 lc "white"
set xr [0:20]
set yr [-3:3]
set term pngcairo size 480,360 font ",10" backgr "#003366"
set key tc "white"

N = 40
do for [i = 0:N-1] {
  t = 3*pi/N * i
  set out sprintf("img%3d.png",i)
  plot f(x,t) ls 101 lw 2 title "Forwarding wave"
}
do for [i = 0:N-1] {
  t = 3*pi/N * i
  set out sprintf("img%3d.png",i+N)
  plot g(x,t) ls 102 lw 2 title "Backwarding wave"
}
do for [i = 0:N-1] {
  t = 3*pi/N * i
  set out sprintf("img%3d.png",i + 2*N)
  plot g(x,t)+f(x,t) ls 100 lw 3 title "Standing wave",\
       f(x,t) ls 101 lw 2 title "Forwarding wave",\
       g(x,t) ls 102  lw 2 title "Backwarding wave"
}
system("convert -adjoin -delay 7 img*.png standing_wave.gif")
system("rm img*.png")