"""SCI Figure Hub — Stacked XRD Diffraction Patterns + Standard PDF Card (CC0-1.0)""" import numpy as np import matplotlib.pyplot as plt PALETTE = ["#3C5488", "#00A087", "#E64B35"] plt.rcParams.update({"font.sans-serif": ["Arial", "DejaVu Sans"], "font.size": 8, "pdf.fonttype": 42}) two_theta = np.linspace(10, 80, 1400) def lorentz(x, x0, amp, w=0.45): return amp * (w**2 / ((x - x0)**2 + w**2)) peaks = [(25.3, 1.0, "(101)"), (37.8, 0.32, "(004)"), (48.0, 0.45, "(200)"), (53.9, 0.28, "(105)"), (62.7, 0.26, "(204)")] fig, ax = plt.subplots(figsize=(3.5, 2.9), dpi=300) for idx, (label, shift, noise) in enumerate([("Pristine", 0.0, 0.015), ("Doped-5%", 0.18, 0.018), ("Composite", -0.15, 0.02)]): y = sum(lorentz(two_theta, p + shift, a) for p, a, _ in peaks) + np.random.default_rng(idx).normal(0, noise, two_theta.size) offset = 0.55 + idx * 1.15 ax.plot(two_theta, y + offset, color=PALETTE[idx], lw=1.15) ax.text(78.5, offset + 0.25, label, ha="right", fontsize=7.5, fontweight="bold", color=PALETTE[idx]) for p, a, hkl in peaks: ax.vlines(p, 0, a * 0.42, color="#475569", lw=1.1) ax.text(p, 3.65, hkl, ha="center", fontsize=6.5, color="#121C26") ax.text(78.5, 0.15, "PDF#21-1272", ha="right", fontsize=6.8, color="#475569", family="monospace") ax.set_xlim(10, 80) ax.set_ylim(0, 4.1) ax.set_yticks([]) ax.set_xlabel("2θ (degree)") ax.set_ylabel("Intensity (a.u.)") fig.tight_layout() fig.savefig("xrd_stack.pdf", bbox_inches="tight")