3D Stem

Audio Spectrum Complex Peaks

Complex frequency spectrum showing audio peaks with magnitude and phase components.

Output
Audio Spectrum Complex Peaks
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(456)

# Audio frequency spectrum peaks
n = 35
frequencies = np.linspace(20, 20000, n)
magnitude = np.random.exponential(0.5, n) * (1 + 2 * np.exp(-(frequencies - 1000)**2 / 500000))
phase = np.random.uniform(-np.pi, np.pi, n)

# Convert to 3D coordinates
x = np.log10(frequencies)
y = magnitude * np.cos(phase)
z = magnitude * np.sin(phase)

fig = plt.figure(figsize=(10, 8), facecolor='#0a0a0f')
ax = fig.add_subplot(111, projection='3d', facecolor='#0a0a0f')

markerline, stemlines, baseline = ax.stem(x, y, z, linefmt='-', markerfmt='o', basefmt=' ')
plt.setp(stemlines, color='#ec4899', linewidth=1.5, alpha=0.7)
plt.setp(markerline, color='#f472b6', markersize=7)

ax.set_xlabel('log₁₀(Frequency)', color='white', fontsize=10)
ax.set_ylabel('Real Component', color='white', fontsize=10)
ax.set_zlabel('Imaginary Component', color='white', fontsize=10)
ax.set_title('Audio Spectrum Complex Peaks', color='white', fontsize=14, fontweight='bold', pad=20)

ax.tick_params(colors='#64748b', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#1e293b')
ax.yaxis.pane.set_edgecolor('#1e293b')
ax.zaxis.pane.set_edgecolor('#1e293b')

ax.view_init(elev=25, azim=45)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support