Home > Back-end >  Animation with gnuplot : only one cruve plotted in an animation whereas 2 expected
Animation with gnuplot : only one cruve plotted in an animation whereas 2 expected

Time:05-27

I have the following script which is expected to produce the animations of 2 curves :

#!/bin/bash

for i in {1..397}; do
gnuplot -p <<-EOFMarker
set terminal png;
set output "pic$i.png";
set title "power spectrum";
set xlabel "scale (k)";
set ylabel "P(k)";
set key top left;
set grid;
set ytics out nomirror;
set xtics out nomirror;
set logscale x;
set logscale y;
set format x "10^{%L}";
set yrange [0:30000];
plot "CAMB-1.3.5/matter_camb$i" u 1:2 w l;
replot "EFTCAMB_v3_beta/matter_eftcamb$i" u 1:2 w l;
EOFMarker
done

# Build movie with ffmpeg
ffmpeg -start_number 1 -i pic%d.png  movie.mpeg

Every works fine excepted the fact that only one curve is plotted in animation (CAMB-1.3.5) :

Here is an example of frame :

enter image description here

Why the "replot" command is not taken into account in the generated image ?

CodePudding user response:

Just for the sake of the SO-rule "no answer in comments":

Check help plot:

Syntax: 

      plot {<ranges>} <plot-element> {, <plot-element>, <plot-element>}
Examples: 

      plot sin(x)
      plot sin(x), cos(x)
      plot f(x) = sin(x*a), a = .2, f(x), a = .4, f(x)
      plot "datafile.1" with lines, "datafile.2" with points
      plot [t=1:10] [-pi:pi*2] tan(t), \
           "data.1" using (tan($2)):($3/$4) smooth csplines \
                    axes x1y2 notitle with lines 5
      plot for [datafile in "spinach.dat broccoli.dat"] datafile
  • Related