Create python script to plot comparison CSV
This commit is contained in:
1 parent
3f325e37fc
commit
953277437b
1 file changed
+27
@@ -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()
|
||||
Reference in new issue
Block a user