-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
50 lines (38 loc) · 1.59 KB
/
Copy pathplot.py
File metadata and controls
50 lines (38 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import sys
import pandas as pd
import matplotlib.pyplot as plt
if len(sys.argv) != 2:
print("Usage: python plot_3body_folder.py path_to_folder")
sys.exit()
folder_path = sys.argv[1]
csv_files = [f for f in os.listdir(folder_path) if f.endswith('.csv')]
plt.figure(figsize=(10, 8))
for file in csv_files:
try:
file_path = os.path.join(folder_path, file)
df = pd.read_csv(file_path, skiprows=5)
# Clean and extract X/Y for 3 segments
segment1 = df[['Position', 'Position.2']].copy()
segment2 = df[['Position.15', 'Position.17']].copy()
segment1 = segment1.apply(pd.to_numeric, errors='coerce').dropna()
segment2 = segment2.apply(pd.to_numeric, errors='coerce').dropna()
# Plot
plt.plot(segment1['Position'], segment1['Position.2'], label=f'{file} - segment 1', marker='o', markersize=.5, linestyle='None')
plt.plot(segment2['Position.15'], segment2['Position.17'], label=f'{file} - segment 2', marker='o', markersize=.5, linestyle='None')
except Exception as e:
print(f"Skipping {file}: {e}")
# Finalize plot
plt.xlabel('Position X (m)')
plt.ylabel('Position Z (m)')
plt.title('2D Trajectories for Edge Radar Range Doppler Experiment')
plt.axis('equal')
plt.grid(True)
plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.) # Legend to the right
plt.tight_layout()
# Save as PDF
plt.savefig("plot.pdf",
format='pdf', bbox_inches='tight', dpi=300)
plt.show()
plt.xlim(-200, 50) # Adjust these as needed
plt.ylim(-50, 200)