#! /bin/bash # # ./plot.sh wordle.txt > wordle-plot.gif # PATH="/bin:/usr/bin"; export PATH case "$1" in "wordle.txt") title="12974 words, 14 qubits";; "wordle-M.txt") title="12974 words, 14 qubits, optimized";; "small.txt") title="7 words, 3 qubits";; "small-O.txt") title="7 words, 3 qubits, optimized";; *) title="";; esac xlabel="iteration" ylabel="probability of correct answer" labels="set title \"$title\"\nset xlabel \"$xlabel\"\nset ylabel \"$ylabel\"" tail -n +2 "$@" | (echo -e "set term gif\nset output\n$labels\nset yrange [0:1]\nplot '-' notitle with linespoints lc rgb 'red'"; cat) | gnuplot # non-standard bash echo -e option to handle backslash-escaped characters