-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw_graph.py
More file actions
97 lines (83 loc) · 3.27 KB
/
draw_graph.py
File metadata and controls
97 lines (83 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import matplotlib.pyplot as plt
import numpy as np
import pickle
# Set professional style
plt.style.use('seaborn-v0_8')
plt.rcParams.update({
'font.size': 10,
'axes.titlesize': 12,
'axes.labelsize': 11,
'xtick.labelsize': 10,
'ytick.labelsize': 10,
'legend.fontsize': 10,
'figure.titlesize': 12,
'lines.linewidth': 1.5,
'patch.linewidth': 0.5,
'axes.linewidth': 0.8,
'grid.alpha': 0.3,
'savefig.bbox': 'tight',
'savefig.pad_inches': 0.1
})
# Load data
pickle_file = "twoq_gate_count_data_all_to_all.pkl"
all_data = pickle.load(open(pickle_file, 'rb'))
input_counts = all_data['input_counts']
compiled_counts = all_data['compiled_counts']
qiskit_counts = all_data['qiskit_counts']
compiled_ratios = all_data['compiled_ratios']
qiskit_ratios = all_data['qiskit_ratios']
# Create figure with two subplots
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))
# Scatter plot (BQSKit vs Qiskit: Two-Qubit Gates)
ax1.scatter(qiskit_ratios, compiled_ratios, alpha=0.7, s=30, color='blue')
ax1.plot([0, 1.05], [0, 1.05], 'r--', linewidth=1.2, alpha=0.8)
ax1.set_xlim(0, 1.05)
ax1.set_ylim(0, 1.05)
ax1.set_ylabel("2Q Gate Percent Remaining (BQSKit)")
ax1.set_xlabel("2Q Gate Percent Remaining (Qiskit)")
ax1.set_title("BQSKit vs Qiskit: Two-Qubit Gates")
ax1.grid(True, alpha=0.3)
ax1.set_aspect('equal')
# Add text annotations for scatter plot
ax1.text(0.1, 0.9, 'Qiskit Better', transform=ax1.transAxes,
fontsize=10, verticalalignment='center',
bbox=dict(boxstyle='round', facecolor='white', alpha=0.7))
ax1.text(0.7, 0.1, 'BQSKit Better', transform=ax1.transAxes,
fontsize=10, verticalalignment='center',
bbox=dict(boxstyle='round', facecolor='white', alpha=0.7))
# Bar chart (Circuit Construction Performance)
benchmarks = ['DTC', 'QV', 'Clifford', 'circSU2']
libraries = ['QISKIT', 'TKet', 'OpenQudit']
data = {
'QISKIT': [0.064329, 0.00106, 1.07867, 0.00193],
'TKet': [1.04467, 0.12237, 0.48965, 0.00292],
'OpenQudit': [0.008437, 0.00681, 0.020544, 0.000253]
}
y = np.arange(len(benchmarks))
height = 0.25
bar_colors = ['#1f77b4', '#ff7f0e', '#2ca02c'] # Consistent color palette
# Plot bars
rects1 = ax2.barh(y + height, data['QISKIT'], height, label='Qiskit', color=bar_colors[0], alpha=0.8)
rects2 = ax2.barh(y, data['TKet'], height, label='TKet', color=bar_colors[1], alpha=0.8)
rects3 = ax2.barh(y - height, data['OpenQudit'], height, label='OpenQudit', color=bar_colors[2], alpha=0.8)
# Formatting
ax2.set_ylabel('Circuit Benchmark')
ax2.set_xlabel('Construction Time (s)')
ax2.set_title('100 Qubit Circuit Construction Performance')
ax2.set_yticks(y)
ax2.set_yticklabels(benchmarks)
ax2.set_xscale('log')
ax2.set_xlim(1e-6, 1e2)
ax2.grid(True, alpha=0.3)
# Highlight lines
ax2.axvline(x=1, color='red', linestyle='--', linewidth=1, alpha=0.8)
ax2.axvline(x=0.1, color='green', linestyle='--', linewidth=1, alpha=0.8)
# Labels for highlight lines (centered vertically)
ax2.text(1.2, len(benchmarks)-2.5, '1 s', color='red', va='center', fontsize=10)
ax2.text(0.12, len(benchmarks)-2.5, '100 ms', color='green', va='center', fontsize=10)
# Legend
ax2.legend(loc='upper right', bbox_to_anchor=(1.0, 1.0))
# Adjust layout
plt.tight_layout()
# Save figure
plt.savefig("combined_paper_charts.png", dpi=600, bbox_inches='tight')