plot_state_qsphere
plot_state_qsphere(rho, figsize=None, ax=None)
Plot the qsphere representation of a quantum state. Here, the size of the points is proportional to the probability of the corresponding term in the state and the color represents the phase.
Parameters
- rho (ndarray) – State vector or density matrix representation. of quantum state.
- figsize (tuple) – Figure size in inches.
- ax (matplotlib.axes.Axes) – An optional Axes object to be used for the visualization output. If none is specified a new matplotlib Figure will be created and used. Additionally, if specified there will be no returned Figure since it is redundant.
Returns
A matplotlib figure instance if the ax
kwag is not set
Return type
Figure
Raises
ImportError – Requires matplotlib.
Example
from qiskit import QuantumCircuit, BasicAer, execute
from qiskit.visualization import plot_state_qsphere
%matplotlib inline
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
backend = BasicAer.get_backend('statevector_simulator')
job = execute(qc, backend).result()
plot_state_qsphere(job.get_statevector(qc))
Was this page helpful?
Report a bug or request content on GitHub.