3D Scatter
Music Genre Audio Embeddings
Audio ML embeddings showing music tracks clustered by genre in 3D feature space.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(680)
# Audio embeddings (e.g., from a neural network)
n_samples = 250
# Genre clusters
genres = ['Rock', 'Jazz', 'Classical', 'Electronic', 'Hip-Hop']
genre_colors = ['#F5276C', '#F5B027', '#4927F5', '#27D3F5', '#6CF527']
all_x, all_y, all_z, all_c = [], [], [], []
for i, (genre, color) in enumerate(zip(genres, genre_colors)):
n = n_samples // 5
# Each genre has its own cluster location
cx = np.cos(i * 2 * np.pi / 5) * 3
cy = np.sin(i * 2 * np.pi / 5) * 3
cz = np.random.uniform(-1, 1)
x = np.random.normal(cx, 0.7, n)
y = np.random.normal(cy, 0.7, n)
z = np.random.normal(cz, 0.5, n)
all_x.extend(x)
all_y.extend(y)
all_z.extend(z)
all_c.extend([color] * n)
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
ax.scatter(all_x, all_y, all_z, c=all_c, s=35, alpha=0.7, edgecolors='white', linewidths=0.2)
ax.set_xlabel('Embedding Dim 1', color='#1f2937', fontsize=10)
ax.set_ylabel('Embedding Dim 2', color='#1f2937', fontsize=10)
ax.set_zlabel('Embedding Dim 3', color='#1f2937', fontsize=10)
ax.set_title('Music Genre Audio Embeddings', color='#1f2937', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')
ax.view_init(elev=20, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
☕