-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphData.py
More file actions
42 lines (34 loc) · 1.23 KB
/
GraphData.py
File metadata and controls
42 lines (34 loc) · 1.23 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
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
csv_file = 'Data\data_log_20260311_174232.csv'
df = pd.read_csv(csv_file)
df['Timestamp'] = pd.to_datetime(df['Timestamp'])
fig, axs = plt.subplots(3, 1, figsize=(10, 12), sharex=True)
# Graph 1: Temperature
axs[0].plot(df['Timestamp'], df['Temperature1H'], label='Temp1H (±0.1)', linestyle='--')
axs[0].plot(df['Timestamp'], df['Temperature2B'], label='Temp2B (±1.5)', linestyle='--')
axs[0].plot(df['Timestamp'], df['Average'], label='Avg.', color='green')
axs[0].set_ylabel('Temperature (°C)')
axs[0].legend()
axs[0].grid(True)
axs[0].set_title('Temperature')
# Graph 2: Pressure
axs[1].plot(df['Timestamp'], df['Pressure'], color='red', label='Pressure')
axs[1].set_ylabel('Pressure (hPa)')
axs[1].legend()
axs[1].grid(True)
axs[1].set_title('Pressure')
# Graph 3: Humidity
axs[2].plot(df['Timestamp'], df['Humidity'], color='cyan', label='Humidity')
axs[2].set_ylabel('Humidity (%)')
axs[2].legend()
axs[2].grid(True)
axs[2].set_title('Humidity')
axs[2].xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
plt.xlabel('Time')
plt.tight_layout()
png_file = csv_file.replace(".csv", ".png")
plt.savefig(f"{png_file}")
print(f"Saved as: {png_file}")
plt.show()