In phase.gp, I use a for loop to iterate over data block (in this
case, each trajectory is in its own block). This gives you nice
per-block colors, but means you'll have to update the loop if you
change the number of energies you're looping over.
# gnuplot plot.gp
# where plot.gp was a gnuplot script for plotting data generated by
# RUN_PROGRAM.
-run: error.png
+run: error.png phase.png
.SECONDEXPANSION:
error-%.data: $(PROGRAMS)
error.png: error.gp error-euler.data error-midpoint.data error-rk4.data
gnuplot "$<" > "$@"
+phase.data:
+ > "$@"
+ for E in 0.1 0.5 1 1.5 2 2.5 3 3.5 4 4.5 4.9 5 5.1 5.5; do \
+ ./one_gaussian_bump --vx0-energy "$$E" >> "$@"; \
+ echo >> "$@"; \
+ echo >> "$@"; \
+ done
+
+phase.png: phase.gp phase.data
+ gnuplot "$<" > "$@"
+
# Pattern rule for compiling object files from C++ source
# There is an implicit rule for this in GNU make
# http://www.gnu.org/software/make/manual/html_node/Catalogue-of-Rules.html
--- /dev/null
+set term png
+set termoption enhanced
+set title 'Phase space'
+set xlabel 'x'
+set ylabel 'v_x'
+unset key
+set yrange [-4.5:0.5]
+k = -5
+b = 1
+V(r) = 0.5 * k * b**2 * exp(-r**2/b**2)
+set style data lines
+plot V(x) title 'V(r)', for [i=0:13] 'phase.data' index i using 2:4