Skip to main contentIBM Quantum Documentation

qiskit.visualization.plot_bloch_vector

qiskit.visualization.plot_bloch_vector(bloch, title='', ax=None, figsize=None, coord_type='cartesian', font_size=None) GitHub(opens in a new tab)

Plot the Bloch sphere.

Plot a Bloch sphere with the specified coordinates, that can be given in both cartesian and spherical systems.

Parameters

Returns

A matplotlib figure instance if ax = None.

Return type

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

Raises

MissingOptionalLibraryError – Requires matplotlib.

Examples

from qiskit.visualization import plot_bloch_vector
 
plot_bloch_vector([0,1,0], title="New Bloch Sphere")
../_images/qiskit-visualization-plot_bloch_vector-1.png
import numpy as np
from qiskit.visualization import plot_bloch_vector
 
# You can use spherical coordinates instead of cartesian.
 
plot_bloch_vector([1, np.pi/2, np.pi/3], coord_type='spherical')
../_images/qiskit-visualization-plot_bloch_vector-2.png
Was this page helpful?