Error Bar Chart
Headphone and Speaker Frequency Response
Audio equipment frequency response curves comparing headphones and studio monitors with measurement uncertainty.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
# Audio frequency response data
frequencies = np.array([20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000])
headphone_a = np.array([-2, 0, 1, 0.5, 0, 0, -0.5, 1, 3, -5])
headphone_b = np.array([1, 2, 0.5, 0, -0.5, 0, 0.5, -1, -2, -8])
speaker = np.array([-5, -2, 0, 0.5, 0, 0, -0.5, 0, -1, -3])
err_a = np.array([0.5, 0.4, 0.3, 0.2, 0.2, 0.2, 0.3, 0.4, 0.6, 1.0])
err_b = np.array([0.6, 0.5, 0.4, 0.3, 0.2, 0.2, 0.3, 0.5, 0.7, 1.2])
err_s = np.array([0.8, 0.6, 0.4, 0.3, 0.2, 0.2, 0.3, 0.4, 0.5, 0.8])
fig, ax = plt.subplots(figsize=(10, 6), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
ax.errorbar(frequencies, headphone_a, yerr=err_a, fmt='o-', color='#F5276C',
ecolor='#F5276C', elinewidth=1.5, capsize=4, markersize=7,
markeredgecolor='white', linewidth=2, label='Headphone A', alpha=0.9)
ax.errorbar(frequencies, headphone_b, yerr=err_b, fmt='s-', color='#27D3F5',
ecolor='#27D3F5', elinewidth=1.5, capsize=4, markersize=7,
markeredgecolor='white', linewidth=2, label='Headphone B', alpha=0.9)
ax.errorbar(frequencies, speaker, yerr=err_s, fmt='^-', color='#6CF527',
ecolor='#6CF527', elinewidth=1.5, capsize=4, markersize=7,
markeredgecolor='white', linewidth=2, label='Studio Monitor', alpha=0.9)
ax.axhline(y=0, color='#F5B027', linestyle='--', linewidth=1.5,
label='Flat Response', alpha=0.7)
ax.fill_between(frequencies, -3, 3, color='#4927F5', alpha=0.1, label='±3dB Target')
ax.set_xscale('log')
ax.set_xlabel('Frequency (Hz)', fontsize=11, color='white', fontweight='500')
ax.set_ylabel('Relative Response (dB)', fontsize=11, color='white', fontweight='500')
ax.set_title('Headphone and Speaker Frequency Response', fontsize=14,
color='white', fontweight='bold', pad=15)
ax.legend(facecolor='#1a1a2e', edgecolor='#333', labelcolor='white',
fontsize=9, loc='lower left')
ax.tick_params(colors='#94a3b8', labelsize=9)
ax.set_ylim(-12, 8)
ax.grid(True, alpha=0.2, color='#4a4a6a')
for spine in ax.spines.values():
spine.set_color('#333333')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Error Bar Chart examples
☕