"""SCI Figure Hub — Violin + Inner Boxplot & Significance Brackets (CC0-1.0)""" import numpy as np import matplotlib.pyplot as plt PALETTE = ["#E64B35", "#4DBBD5", "#00A087", "#3C5488"] plt.rcParams.update({"font.sans-serif": ["Arial", "DejaVu Sans"], "font.size": 8, "axes.spines.top": False, "axes.spines.right": False, "pdf.fonttype": 42}) rng = np.random.default_rng(19) labels = ["Healthy", "Stage I", "Stage II", "Stage III"] groups = [rng.normal(2.1, 0.55, 60), rng.normal(3.4, 0.72, 60), rng.normal(4.8, 0.85, 60), rng.normal(6.0, 0.78, 60)] fig, ax = plt.subplots(figsize=(3.5, 2.55), dpi=300) vp = ax.violinplot(groups, showmeans=False, showextrema=False, widths=0.72) for body, col in zip(vp["bodies"], PALETTE): body.set_facecolor(col) body.set_edgecolor("#1E293B") body.set_linewidth(0.6) body.set_alpha(0.42) ax.boxplot(groups, widths=0.16, showfliers=False, patch_artist=True, boxprops={"facecolor": "#FFFFFF", "edgecolor": "#121C26", "linewidth": 0.9}, medianprops={"color": "#121C26", "linewidth": 1.4}, whiskerprops={"color": "#121C26", "linewidth": 0.8}, capprops={"linewidth": 0}) # Significance brackets for x1, x2, y, stars in [(1, 2, 7.6, "**"), (1, 4, 8.6, "***")]: ax.plot([x1, x1, x2, x2], [y - 0.25, y, y, y - 0.25], color="#121C26", lw=0.8) ax.text((x1 + x2) / 2, y + 0.08, stars, ha="center", va="bottom", fontsize=8, fontweight="bold") ax.set_xticks(range(1, 5), labels) ax.set_ylim(0.2, 9.6) ax.set_ylabel("Biomarker Score (a.u.)") fig.tight_layout() fig.savefig("violin_stats.pdf", bbox_inches="tight")