Bloch disc

import numpy as np
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
import kaleidoscope.qiskit
from kaleidoscope import bloch_disc

From a vector of Bloch components

vec = [1/np.sqrt(2), 1/np.sqrt(2), 0]
bloch_disc(vec)

From a Qiskit statevector

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)

From a Qiskit statevector using kaleidoscope overloading

qc = QuantumCircuit(1)
qc.ry(np.pi*np.random.random(), 0)
qc.rz(np.pi*np.random.random(), 0)

bloch_disc(qc.statevector())

Change colormap

from matplotlib.cm import cool_r

qc = QuantumCircuit(1)
qc.ry(1, 0)
qc.t(0)

bloch_disc(qc.statevector(), colormap=cool_r)

Adding a title

vec = [1/np.sqrt(3), 1/np.sqrt(3), -1/np.sqrt(3)]
bloch_disc(vec, title='My qubit')