From 0abe919535ce29d251d18c4b32a948fbe325bbc2 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 17 Oct 2026 18:46:33 +0100 Subject: [PATCH] Create python script to plot comparison CSV --- plot.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 plot.py diff --git a/plot.py b/plot.py new file mode 100755 index 0000000..7c3d982 --- /dev/null +++ b/plot.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import sys + +import matplotlib.pyplot as plt +import pandas as pd + + +def main(): + src = sys.argv[1] if len(sys.argv) > 1 else sys.stdin + df = pd.read_csv(src) + + fig, ax = plt.subplots(figsize=(10, 5)) + ax.plot(df["time"], df["tao"], label="Tao (symplectic)", linewidth=1) + ax.plot(df["time"], df["rk4"], label="RK4", linewidth=1) + + ax.set_xlabel("Time") + ax.set_ylabel("Energy") + ax.set_title("Double pendulum energy: RK4 vs Tao's method") + ax.legend() + ax.grid(True, alpha=0.3) + + fig.tight_layout() + plt.show() + + +if __name__ == "__main__": + main()