Event Plot

Quantum Circuit Visualization

Multi-qubit gate sequence with entanglement operations

Output
Quantum Circuit Visualization
Python
import matplotlib.pyplot as plt
import numpy as np

# Simulate quantum circuit gate events
np.random.seed(42)
qubits = ['Q0', 'Q1', 'Q2', 'Q3', 'Q4']
gate_sequences = [
    np.array([0, 2, 4, 6, 8, 10, 14, 18]),
    np.array([1, 3, 5, 7, 11, 15, 19]),
    np.array([0, 1, 4, 5, 8, 12, 16]),
    np.array([2, 6, 9, 13, 17]),
    np.array([3, 7, 10, 14, 18]),
]

# Two-qubit gate pairs
entanglement_events = [(0, 1, 1), (1, 2, 5), (2, 3, 9), (3, 4, 14), (0, 4, 18)]

# Quantum-inspired colors
colors = ['#06B6D4', '#8B5CF6', '#EC4899', '#F59E0B', '#10B981']

# Create figure
fig, ax = plt.subplots(figsize=(12, 6), facecolor='#030712')
ax.set_facecolor('#030712')

# Single qubit gates
for i, (gates, color) in enumerate(zip(gate_sequences, colors)):
    # Glow effect
    for lw, alpha in [(10, 0.1), (6, 0.2), (3, 0.5)]:
        ax.eventplot(gates, lineoffsets=i, linelengths=0.4, linewidths=lw,
                     colors=color, alpha=alpha)
    ax.eventplot(gates, lineoffsets=i, linelengths=0.3, linewidths=1,
                 colors='white', alpha=0.8)

# Entanglement connections (CNOT gates)
for q1, q2, t in entanglement_events:
    ax.plot([t, t], [q1, q2], color='#FBBF24', linewidth=2, alpha=0.6)
    ax.scatter([t, t], [q1, q2], c='#FBBF24', s=50, zorder=10)

# Measurement zone
ax.axvspan(18, 20, color='#DC2626', alpha=0.15, zorder=0)
ax.text(19, 4.7, 'Measure', ha='center', fontsize=10, color='#DC2626', fontweight='500')

# Circuit depth markers
for d in range(0, 21, 5):
    ax.axvline(d, color='#1F2937', linewidth=1, linestyle=':')

# Styling
ax.set_yticks(range(len(qubits)))
ax.set_yticklabels(qubits, fontsize=12, fontweight='700', color='white', family='monospace')
ax.set_xlabel('Circuit Depth', fontsize=12, fontweight='500', color='#9CA3AF')
ax.set_xlim(-1, 21)
ax.set_ylim(-0.5, len(qubits) - 0.5)

ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#1F2937')
ax.spines['bottom'].set_color('#1F2937')
ax.tick_params(colors='#9CA3AF', labelsize=10)

# Legend
ax.scatter([], [], c='#FBBF24', s=50, label='CNOT Gate')
ax.plot([], [], color='#06B6D4', linewidth=3, label='Single Gate')
ax.legend(loc='upper right', frameon=True, facecolor='#0F172A', 
          edgecolor='#1F2937', labelcolor='white', fontsize=9)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support