File size: 1,111 Bytes
ab45969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
import matplotlib.pyplot as plt

# 读取JSON文件
with open('action_val.json', 'r') as file:
    data = json.load(file)

# 提取数据
scene_data = data[1]
action_pred = scene_data["action_pred"]
action_gt = scene_data["action_gt"]

# 提取转向角和速度
pred_steering_angles = [a[0] for a in action_pred]
pred_speeds = [a[1] for a in action_pred]

gt_steering_angles = [a[0] for a in action_gt]
gt_speeds = [a[1] for a in action_gt]

# 绘图
plt.figure(figsize=(12, 5))

# 转向角的 plot
plt.subplot(1, 2, 1)
plt.plot(pred_steering_angles, label='Predicted Steering Angle', color='blue', marker='o')
plt.plot(gt_steering_angles, label='Ground Truth Steering Angle', color='orange', marker='o')
plt.title("Steering Angle")
plt.xlabel("Time Step")
plt.ylabel("Angle")
plt.legend()

# 速度的 plot
plt.subplot(1, 2, 2)
plt.plot(pred_speeds, label='Predicted Speed', color='blue', marker='o')
plt.plot(gt_speeds, label='Ground Truth Speed', color='orange', marker='o')
plt.title("Speed")
plt.xlabel("Time Step")
plt.ylabel("Speed")
plt.legend()

plt.tight_layout()
plt.savefig('val.jpg')