echo  "set datafile separator ',';"\
      "set bmargin 0;"\
      "set tmargin 0;"\
      "set lmargin 10;"\
      "set rmargin 3;"\
      "set xtics (10,20,30,40);"\
      "unset xlabel;"\
      "set ytics (0);"\
      "set multiplot layout 6,2 columnsfirst title 'GOLEM Shot $shot_no';"\
      "set xrange [*:*];"\
      "set style data dots;"\
    > tmp

# Prvni sestice R1-R6: najdeme rozsah podle prumeru ± 3x std
{
  echo "stats 'ch1.csv' using 2 name 'SR';"
  echo "rangeR = 1.0 * SR_stddev;"
  echo "yminR = SR_mean - rangeR;"
  echo "ymaxR = SR_mean + rangeR;"

  for i in $(seq 1 6); do
      echo "set yrange [0.1*yminR:ymaxR];"
      echo "set ytics (0, ymaxR);"
      echo "set ylabel 'R$((i-0))'; plot 'ch$i.csv' u 1:2 t '' w l lc 1;"
  done
} >> tmp

# Druha sestice L1-L6: najdeme rozsah podle prumeru ± 3x std
{
  echo "stats 'ch7.csv' using 2 name 'SL';"
  echo "rangeL = 8.0 * SL_stddev;"
  echo "yminL = SL_mean - rangeL;"
  echo "ymaxL = SL_mean + rangeL;"

  for i in $(seq 7 12); do
      echo "set yrange [yminL:ymaxL];"
      echo "set ytics (0, ymaxL);"
      echo "set ylabel 'L$((i-6))'; plot 'ch$i.csv' u 1:2 t '' w l lc 1;"
  done
} >> tmp
