pushup
This commit is contained in:
62
lab2_part1.py
Normal file
62
lab2_part1.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme(style="whitegrid", palette="muted")
|
||||
|
||||
# File paths for golf ball data
|
||||
golf_file_paths = {
|
||||
"11 inches": "golf_11.csv",
|
||||
"12 inches": "golf_12.csv",
|
||||
"13 inches": "golf_13.csv",
|
||||
"14 inches": "golf_14.csv",
|
||||
"15 inches": "golf_15.csv"
|
||||
}
|
||||
|
||||
# File paths for lacrosse ball data
|
||||
lacrosse_file_paths = {
|
||||
"18 inches": "l_18.csv",
|
||||
"19 inches": "l_19.csv",
|
||||
"20 inches": "l_20.csv",
|
||||
"21 inches": "l_21.csv",
|
||||
"22 inches": "l_22.csv"
|
||||
}
|
||||
|
||||
# File paths for metal ball data
|
||||
metal_file_paths = {
|
||||
"2 inches": "metal_2.csv",
|
||||
"4 inches": "metal_4.csv",
|
||||
"6 inches": "metal_6.csv",
|
||||
"8 inches": "metal_8.csv",
|
||||
"10 inches": "metal_10.csv"
|
||||
}
|
||||
|
||||
def plot_position_vs_time(file_paths, ball_type):
|
||||
for label, path in file_paths.items():
|
||||
# Read CSV with no header, assuming columns: Time, Position
|
||||
df = pd.read_csv(path, header=None, names=["Time", "Position"])
|
||||
|
||||
fig, ax = plt.subplots(figsize=(10, 6))
|
||||
|
||||
ax.plot(df["Time"], df["Position"], label=label, marker='o', markersize=3, linewidth=2)
|
||||
|
||||
ax.set_xlabel("Time (seconds)", fontsize=14)
|
||||
ax.set_ylabel("Position (inches)", fontsize=14)
|
||||
ax.set_title(f"{ball_type} - Position vs. Time\nInitial Height: {label}", fontsize=16, pad=15)
|
||||
|
||||
ax.grid(True, which='both', linestyle='--', linewidth=0.5, alpha=0.7)
|
||||
|
||||
ax.legend(fontsize=12)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
#plt.savefig()
|
||||
|
||||
# Plot golf ball data
|
||||
plot_position_vs_time(golf_file_paths, "Golf Ball")
|
||||
|
||||
# Plot lacrosse ball data
|
||||
plot_position_vs_time(lacrosse_file_paths, "Lacrosse Ball")
|
||||
|
||||
# Plot metal ball data
|
||||
plot_position_vs_time(metal_file_paths, "Metal Ball")
|
||||
Reference in New Issue
Block a user