Dashboard Core — State Visuals¶
Native statevector visualizations — histogram, Q-sphere, per-qubit Bloch spheres — pure matplotlib/numpy, no Qiskit anywhere.
import numpy as np
from dashboard_core.state_visuals import (
native_histogram_figure, native_bloch_multivector_figure, native_qsphere_figure,
)
bell = np.array([1, 0, 0, 1]) / np.sqrt(2) # (|00> + |11>)/sqrt(2)
native_histogram_figure({"00": 512, "11": 488}).savefig("histogram.png")
native_bloch_multivector_figure(bell).savefig("bloch.png") # both spheres point to the origin -- maximally mixed
native_qsphere_figure(bell).savefig("qsphere.png") # two equal-size dots at the poles
state_visuals ¶
Native statevector visualizations -- histogram, Q-sphere, per-qubit Bloch spheres -- pure matplotlib/numpy, no Qiskit anywhere. Replaces qiskit.visualization.{plot_histogram, plot_state_qsphere, plot_bloch_multivector}, the last three real Qiskit call sites in this project's dashboard (the circuit diagram itself was already native, see circuit_diagram.py's own docstring for why that mattered on macOS). Qiskit's own instability on macOS CI runners was never proven scoped to just QuantumCircuit -- no reason the plotting functions built on top of it are exempt -- so removing them entirely, not just making qiskit optional, is the actual fix.
All inputs use Qiskit's little-endian bit convention (qubit 0 = least significant bit of the statevector index), matching dashboard_core.engine's own SimulationResult.statevector -- the same convention plot_state_qsphere/plot_bloch_multivector assumed.
native_histogram_figure ¶
Bar chart of shot counts, bitstrings sorted ascending -- the same information qiskit.visualization.plot_histogram showed, built from nothing but the counts dict itself.
statevector (optional): when given, each bar is colored by the
complex phase of that basis state's amplitude (same HSV cyclic
colormap and convention as native_qsphere_figure's own phase
coloring) instead of the flat default color -- a state's phase is
real physical information invisible in a bare shot-count bar
otherwise. statevector must be in the same Qiskit little-endian
convention as counts' own bitstrings (see module docstring).
Examples:
>>> from dashboard_core.state_visuals import native_histogram_figure
>>> fig = native_histogram_figure({'00': 512, '11': 488})
>>> type(fig).__name__
'Figure'
Source code in tools/dashboard/core/state_visuals.py
native_bloch_multivector_figure ¶
One Bloch sphere per qubit, each from that qubit's own reduced density matrix (partial trace over every other qubit) -- the same per-qubit view qiskit.visualization.plot_bloch_multivector showed, computed directly from the real statevector, no Qiskit involved.
Examples:
>>> import numpy as np
>>> from dashboard_core.state_visuals import native_bloch_multivector_figure
>>> bell = np.array([1, 0, 0, 1]) / np.sqrt(2)
>>> fig = native_bloch_multivector_figure(bell)
>>> type(fig).__name__
'Figure'
Source code in tools/dashboard/core/state_visuals.py
native_qsphere_figure ¶
Q-sphere: every basis state with non-negligible probability placed on a sphere by Hamming weight (latitude -- |00...0> at the north pole, |11...1> at the south pole, states of equal weight sharing a ring), marker size by probability, marker color by phase (cyclic colormap, matching Qiskit's own convention) -- the same encoding qiskit.visualization.plot_state_qsphere used, built directly from the statevector's own amplitudes.
Examples:
>>> import numpy as np
>>> from dashboard_core.state_visuals import native_qsphere_figure
>>> bell = np.array([1, 0, 0, 1]) / np.sqrt(2)
>>> fig = native_qsphere_figure(bell)
>>> type(fig).__name__
'Figure'
Source code in tools/dashboard/core/state_visuals.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
See also: dashboard_core.visuals, which
aggregates this with circuit_diagram.