-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_generator.py
More file actions
33 lines (23 loc) · 929 Bytes
/
Copy pathplot_generator.py
File metadata and controls
33 lines (23 loc) · 929 Bytes
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
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("output.csv")
df['timestamp'] = pd.to_numeric(df['timestamp'])
t0 = df['timestamp'].iloc[0]
df['t'] = df['timestamp'] - t0
real = df[df['type'] == 'real']
forecast = df[df['type'] == 'forecast']
plt.figure()
plt.bar(real['t'], real['value'], label='Real')
plt.plot(forecast['t'], forecast['value'], color='red', linestyle='--', label='Forecast')
for i, (x, y) in enumerate(zip(real['t'], real['value'])):
if i % 2 == 0:
offset = 1 if i % 4 == 0 else 3
plt.text(x, y + offset, f'{y:.1f}', ha='center', va='bottom', fontsize=8)
for i, (x, y) in enumerate(zip(forecast['t'], forecast['value'])):
if i % 2 == 0:
plt.text(x, y + 4, f'{y:.1f}', ha='center', va='bottom', fontsize=8, color='red')
plt.legend()
plt.xlabel("Time (s)")
plt.ylabel("Value")
plt.title("Real vs Forecast")
plt.show()