Boxplot

Quantum Gate Fidelity

Fidelity measurements across quantum gate operations

Output
Quantum Gate Fidelity
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)
gates = ['Hadamard', 'CNOT', 'Toffoli', 'T-Gate', 'SWAP']
data = [
    0.99 - np.random.exponential(0.005, 150),
    0.985 - np.random.exponential(0.008, 150),
    0.975 - np.random.exponential(0.012, 150),
    0.995 - np.random.exponential(0.003, 150),
    0.98 - np.random.exponential(0.01, 150)
]

fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor('#0d1117')
fig.patch.set_facecolor('#0d1117')

colors = ['#4927F5', '#276CF5', '#27D3F5', '#27F5B0', '#6CF527']
bp = ax.boxplot(data, widths=0.55, patch_artist=True, showfliers=True,
                flierprops=dict(marker='d', markerfacecolor='#F5276C', markersize=3, alpha=0.6),
                medianprops=dict(color='#F5D327', linewidth=2.5))

for patch, color in zip(bp['boxes'], colors):
    patch.set_facecolor(color)
    patch.set_alpha(0.85)
    patch.set_edgecolor('white')
    patch.set_linewidth(1.5)
for i, color in enumerate(colors):
    bp['whiskers'][i*2].set_color(color)
    bp['whiskers'][i*2+1].set_color(color)
    bp['caps'][i*2].set_color(color)
    bp['caps'][i*2+1].set_color(color)

ax.axhline(0.99, color='#F5B027', linewidth=1, linestyle='--', alpha=0.7, label='Target Fidelity')
ax.set_xticklabels(gates)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#333333')
ax.spines['bottom'].set_color('#333333')
ax.yaxis.grid(True, color='#1a1a3f', linewidth=0.5, zorder=0)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors='#888888', labelsize=9, length=0, pad=8)
ax.set_ylabel('Fidelity', fontsize=11, color='white', fontweight='500')
ax.set_title('Quantum Gate Fidelity Analysis', fontsize=14, color='white', fontweight='bold', pad=15)
ax.legend(loc='lower right', facecolor='#0d1117', edgecolor='#333333', labelcolor='white')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support