qiskit.visualization.plot_bloch_multivector
plot_bloch_multivector(state, title='', figsize=None, *, rho=None, reverse_bits=False, filename=None)
Plot a Bloch sphere for each qubit.
Each component 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 , where is the number of qubits, and is the identity operator.
Parameters
- state (Statevector orDensityMatrix or ndarray) – an N-qubit quantum state.
- title (str) – a string that represents the plot title
- figsize (tuple) – Has no effect, here for compatibility only.
- reverse_bits (bool) – If True, plots qubits following Qiskit’s convention [Default:False].
Returns
A matplotlib figure instance.
Return type
matplotlib.Figure
Raises
- MissingOptionalLibraryError – Requires matplotlib.
- VisualizationError – if input is not a valid N-qubit state.
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)
(Source code, png, hires.png, pdf)
![../_images/qiskit-visualization-plot_bloch_multivector-1.png](/_next/image?url=%2Fimages%2Fapi%2Fqiskit%2F0.40%2Fqiskit-visualization-plot_bloch_multivector-1.png&w=1920&q=75)
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)
(Source code, png, hires.png, pdf)
![../_images/qiskit-visualization-plot_bloch_multivector-2.png](/_next/image?url=%2Fimages%2Fapi%2Fqiskit%2F0.40%2Fqiskit-visualization-plot_bloch_multivector-2.png&w=1920&q=75)
Was this page helpful?
Report a bug or request content on GitHub.