Create python script to plot comparison CSV

This commit is contained in:
cdo committed 2026-10-17 18:53:22 +01:00
1 parent d4f500956f
commit 0abe919535
1 file changed
+27
Executable
+27
View File
@@ -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()