bloch_disc

bloch_disc(rho, figsize=None, title=None, colormap=None, as_widget=False)[source]

Plot a Bloch disc for a single qubit.

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

  • figsize (tuple) – Figure size in pixels, default=(200,275).

  • title (str) – Plot title.

  • 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_disc
qc = QuantumCircuit(1)
qc.ry(np.pi*np.random.random(), 0)
qc.rz(np.pi*np.random.random(), 0)

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