Skip to main contentIBM Quantum Documentation

qiskit.visualization.plot_bloch_multivector

qiskit.visualization.plot_bloch_multivector(state, title='', figsize=None, *, reverse_bits=False, filename=None, font_size=None, title_font_size=None, title_pad=1)GitHub(opens in a new tab)

Plot a Bloch sphere for each qubit.

Each component (x,y,z)(x,y,z) of the Bloch sphere labeled as ‘qubit i’ represents the expected value of the corresponding Pauli operator acting only on that qubit, that is, the expected value of IN1Ii+1PiIi1I0I_{N-1} \otimes\dotsb\otimes I_{i+1}\otimes P_i \otimes I_{i-1}\otimes\dotsb\otimes I_0, where NN is the number of qubits, P{X,Y,Z}P\in \{X,Y,Z\} and II is the identity operator.

Parameters

Returns

A matplotlib figure instance.

Return type

matplotlib.figure.Figure(opens in a new tab)

Raises

Examples

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_bloch_multivector
 
qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
 
state = Statevector(qc)
plot_bloch_multivector(state)
../_images/qiskit-visualization-plot_bloch_multivector-1.png
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_bloch_multivector
 
qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
 
# You can reverse the order of the qubits.
 
from qiskit.quantum_info import DensityMatrix
 
qc = QuantumCircuit(2)
qc.h([0, 1])
qc.t(1)
qc.s(0)
qc.cx(0,1)
 
matrix = DensityMatrix(qc)
plot_bloch_multivector(matrix, title='My Bloch Spheres', reverse_bits=True)
../_images/qiskit-visualization-plot_bloch_multivector-2.png
Was this page helpful?