ANOVA Boxplot

AV Sensor Detection ANOVA

Comparing object detection accuracy across autonomous vehicle sensor types.

Output
AV Sensor Detection ANOVA
Python
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats

np.random.seed(999)

# Detection accuracy percentage
lidar = np.random.normal(96.5, 2.0, 100)
radar = np.random.normal(89.2, 3.5, 100)
camera = np.random.normal(92.8, 2.8, 100)
ultrasonic = np.random.normal(78.5, 5.0, 100)

lidar = np.clip(lidar, 88, 100)
radar = np.clip(radar, 75, 98)
camera = np.clip(camera, 82, 99)
ultrasonic = np.clip(ultrasonic, 60, 92)

F_stat, p_value = stats.f_oneway(lidar, radar, camera, ultrasonic)

fig, ax = plt.subplots(figsize=(12, 7), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

colors = ['#6CF527', '#F5B027', '#27D3F5', '#F5276C']
data = [lidar, radar, camera, ultrasonic]

bp = ax.boxplot(data, positions=[1, 2, 3, 4], widths=0.6, patch_artist=True,
                medianprops={'color': 'white', 'linewidth': 2},
                whiskerprops={'color': '#555555', 'linewidth': 1.5},
                capprops={'color': '#555555', 'linewidth': 1.5},
                flierprops={'marker': 'o', 'markerfacecolor': '#444444', 'markersize': 4})

for patch, color in zip(bp['boxes'], colors):
    patch.set_facecolor(color)
    patch.set_alpha(0.7)
    patch.set_edgecolor('white')
    patch.set_linewidth(1.5)

labels = ['LiDAR', 'Radar', 'Camera', 'Ultrasonic']

# Safety threshold
ax.axhline(y=95, color='#22c55e', linestyle='--', alpha=0.7, linewidth=1.5)
ax.text(4.45, 95, 'L4 Req', fontsize=8, color='#22c55e', va='center')

# Range and cost
ranges = ['200m', '250m', '150m', '5m']
costs = ['$10K', '$500', '$200', '$50']
for i, (d, rng, cost, color) in enumerate(zip(data, ranges, costs, colors)):
    ax.text(i+1, 55, f'Range:{rng} | {cost}', ha='center', fontsize=8, color=color)

# Stats header
stats_text = f"ANOVA: F={F_stat:.1f}, p<0.001 | Best Accuracy: LiDAR (μ={lidar.mean():.1f}%)"
bbox = dict(boxstyle="round,pad=0.3", facecolor='#020B14', edgecolor='#6CF527', lw=2)
ax.text(0.5, 1.02, stats_text, transform=ax.transAxes, fontsize=9, color='white',
        ha='center', va='bottom', fontfamily='monospace', bbox=bbox)

ax.set_xticks([1, 2, 3, 4])
ax.set_xticklabels(labels, fontsize=11, color='white')
ax.set_ylabel('Detection Accuracy (%)', fontsize=12, color='white', fontweight='500')
ax.set_title('Autonomous Vehicle Sensor Performance\nObject Detection in Urban Environment', 
             fontsize=14, color='white', fontweight='bold', pad=25)

ax.tick_params(colors='#888888')
for spine in ax.spines.values():
    spine.set_color('#333333')
ax.yaxis.grid(True, color='#1a1a2e', linewidth=0.5)
ax.set_axisbelow(True)
ax.set_ylim(52, 102)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support