bloch_multi_disc

bloch_multi_disc(rho, figsize=None, titles=True, colormap=None, as_widget=False)[source]

Plot Bloch discs for a multi-qubit state.

Parameters
  • rho (list or ndarray or Statevector or DensityMatrix) – Input statevector, density matrix.

  • figsize (tuple) – Figure size in pixels, default=(125*num_qubits, 150).

  • titles (bool) – Display titles.

  • colormap (Colormap) – A matplotlib colormap.

  • as_widget (bool) – Return plot as a widget.

Returns

A Plotly figure instance PlotlyWidget : A Plotly widget if as_widget=True.

Return type

PlotlyFigure

Example

import numpy as np
from qiskit import *
from qiskit.quantum_info import Statevector
from kaleidoscope.interactive import bloch_multi_disc

N = 4
qc = QuantumCircuit(N)
qc.h(range(N))
for kk in range(N):
    qc.ry(2*np.pi*np.random.random(), kk)
for kk in range(N-1):
    qc.cx(kk,kk+1)
for kk in range(N):
    qc.rz(2*np.pi*np.random.random(), kk)

state = Statevector.from_instruction(qc)
bloch_multi_disc(state)