Stage2024/tracking_sources/graphing.py
2024-06-28 14:08:49 +02:00

46 lines
1.1 KiB
Python

# Graphing script
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import sys
# Read csv path
args = sys.argv
path = args[1]
# open csv
df = pd.read_csv(path)
print(df)
# compute the error
df["dr1m1"] = abs(df["r1m1"] - df["reel"])
df["dr2m1"] = abs(df["r2m1"] - df["reel"])
df["dr3m1"] = abs(df["r3m1"] - df["reel"])
df["dr4m1"] = abs(df["r4m1"] - df["reel"])
# Plotting the distance seen vs real
plt.plot(df["reel"], df["reel"], label="Real")
plt.plot(df["reel"], df["r1m1"], label="r1m1")
plt.plot(df["reel"], df["r2m1"], label="r2m1")
plt.plot(df["reel"], df["r3m1"], label="r3m1")
plt.plot(df["reel"], df["r4m1"], label="r4m1")
plt.xlabel("Distance (m)")
plt.ylabel("Distance (m)")
plt.title("Real vs Seen Distance")
plt.legend()
plt.show()
# Plotting the error over distance
# plt.plot(df["reel"], df["dr1m1"], label="r1m1")
# plt.plot(df["reel"], df["dr2m1"], label="r2m1")
# plt.plot(df["reel"], df["dr3m1"], label="r3m1")
plt.plot(df["reel"], df["dr4m1"], label="r4m1")
plt.xlabel("Distance (m)")
plt.ylabel("Error (m)")
plt.title("Tracking Error over Distance")
plt.legend()
plt.show()