Reputation: 129
I need to plot a couple of curves in a single window. Using for loop in bash shell I've been able to plot them on separate files , but no success in sketching them on a single pic. I would appreciate it if you can guide me on how to resolve this issue.
I tried to implement the example in thie link for loop inside gnuplot? but it gives me an error saying: ':' expected .I have gnuplot 4.2 installed. Thanks,
#!/bin/bash
for Counter in {1..9}; do
FILE="dataFile"$Counter".data"
gnuplot <<EOF
set xlabel "k"
set ylabel "p(k)"
set term png
set output "${FILE}.png"
plot [1:50] '${FILE}'
EOF
done
Upvotes: 1
Views: 1125
Reputation: 48390
Looping inside the plot
command works only since version 4.4 and would look like
file(n) = sprintf("dataFile%d.data", n)
plot for [i=1:9] file(i)
Using bash I would construct the plot
command inside the bash loop and use this later in the gnuplot script:
for Counter in {1..9}; do
FILE="dataFile${Counter}.data"
if [ $Counter = 1 ]; then
plot="plot '$FILE'"
else
plot=$plot", '$FILE'"
fi
done
gnuplot <<EOF
set xlabel "k"
set ylabel "p(k)"
set term png
set output "output.png"
$plot
EOF
Upvotes: 1