Hexbin Plot

Audio Frequency Response

Frequency spectrum analyzer visualization

Output
Audio Frequency Response
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)
freqs = np.logspace(1, 4.3, 100)  # 10 Hz to 20 kHz

# Frequency response curve
response = 80 - 10*np.log10(1 + (freqs/1000)**2) + 20*np.exp(-((np.log10(freqs) - 2.5)**2)/0.3)
response += np.random.normal(0, 2, len(freqs))

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

# Gradient effect with multiple fills
colors = ['#4927F5', '#27D3F5', '#6CF527', '#F5B027', '#F5276C']
for i, color in enumerate(colors):
    level = 20 + i * 15
    ax.fill_between(freqs, level, np.minimum(response, level + 15), 
                    where=(response > level), alpha=0.4, color=color)

ax.plot(freqs, response, color='white', linewidth=1.5)

# Frequency bands
ax.axvline(250, color='#333333', linewidth=0.5, linestyle=':')
ax.axvline(2000, color='#333333', linewidth=0.5, linestyle=':')
ax.axvline(6000, color='#333333', linewidth=0.5, linestyle=':')

ax.text(50, 95, 'Bass', color='#888888', fontsize=9)
ax.text(700, 95, 'Mids', color='#888888', fontsize=9)
ax.text(3500, 95, 'Highs', color='#888888', fontsize=9)

ax.set_xscale('log')
ax.set_xlabel('Frequency (Hz)', color='white', fontsize=11)
ax.set_ylabel('Amplitude (dB)', color='white', fontsize=11)
ax.set_title('Audio Frequency Spectrum', color='white', fontsize=14, fontweight='bold', pad=15)
ax.tick_params(colors='#888888', labelsize=9)
for spine in ax.spines.values():
    spine.set_color('#333333')
ax.set_xlim(10, 20000)
ax.set_ylim(20, 100)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support