Raincloud Plot
Audio Streaming Quality Raincloud
Distribution of audio quality scores across music streaming platforms.
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
np.random.seed(888)
# Audio quality score (perceptual, 0-100)
spotify = np.random.normal(78, 6, 100)
apple = np.random.normal(85, 5, 95)
tidal = np.random.normal(92, 3, 80)
amazon = np.random.normal(82, 5.5, 90)
spotify = np.clip(spotify, 60, 92)
apple = np.clip(apple, 70, 96)
tidal = np.clip(tidal, 82, 100)
amazon = np.clip(amazon, 65, 94)
F_stat, p_value = stats.f_oneway(spotify, apple, tidal, amazon)
BG_COLOR = "#0a0a0f"
COLOR_SCALE = ["#6CF527", "#F5276C", "#27D3F5", "#F5B027"]
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
y_data = [spotify, apple, tidal, amazon]
positions = [0, 1, 2, 3]
labels = ["Spotify", "Apple Music", "Tidal", "Amazon HD"]
for h in [70, 80, 90]:
ax.axhline(h, color='#333333', ls=(0, (5, 5)), alpha=0.5, zorder=0)
# Quality tiers
ax.axhspan(90, 100, alpha=0.08, color='#22c55e')
ax.text(3.55, 95, "Hi-Res", color='#22c55e', fontsize=9, va='center')
ax.text(3.55, 83, "CD Quality", color='#fbbf24', fontsize=9, va='center')
violins = ax.violinplot(y_data, positions=positions, widths=0.5,
bw_method="silverman", showmeans=False,
showmedians=False, showextrema=False)
for pc in violins["bodies"]:
pc.set_facecolor("none")
pc.set_edgecolor("white")
pc.set_linewidth(1.8)
bp = ax.boxplot(y_data, positions=positions, showfliers=False, showcaps=False,
medianprops=dict(linewidth=3, color='#F5D327'),
whiskerprops=dict(linewidth=2, color='#555555'),
boxprops=dict(linewidth=2, color='#555555'))
for i, (y, color) in enumerate(zip(y_data, COLOR_SCALE)):
x_jitter = np.array([i] * len(y)) + stats.t(df=6, scale=0.04).rvs(len(y))
ax.scatter(x_jitter, y, s=50, color=color, alpha=0.5, zorder=2)
means = [y.mean() for y in y_data]
for i, (mean, color) in enumerate(zip(means, COLOR_SCALE)):
ax.scatter(i, mean, s=180, color='#C82909', zorder=5, edgecolors='white', linewidths=2)
ax.plot([i, i + 0.28], [mean, mean], ls="dashdot", color="white", zorder=3, lw=1.5)
ax.text(i + 0.3, mean, f"μ={mean:.1f}", fontsize=10, va="center", color='white',
bbox=dict(facecolor=BG_COLOR, edgecolor=color, boxstyle="round,pad=0.15", lw=2))
# Bitrate annotations
bitrates = ["320kbps", "256kbps AAC", "1411kbps", "850kbps"]
for i, (br, color) in enumerate(zip(bitrates, COLOR_SCALE)):
ax.text(i, 57, br, ha='center', fontsize=9, color=color)
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.spines["left"].set_color('#444444')
ax.spines["bottom"].set_color('#444444')
ax.tick_params(colors='#888888', length=0)
xlabels = [f"{l}\n(n={len(y_data[i])})" for i, l in enumerate(labels)]
ax.set_xticks(positions)
ax.set_xticklabels(xlabels, size=11, color='white')
ax.set_ylabel("Perceptual Audio Quality Score", size=14, color='white', fontweight='bold')
ax.set_title("Audio Streaming Quality Analysis", fontsize=14, color="white", fontweight="bold", pad=20)
ax.set_ylim(55, 102)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Raincloud Plot examples
☕