Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

plot_state_hinton

plot_state_hinton(rho, title='', figsize=None, ax_real=None, ax_imag=None)

GitHub(opens in a new tab)

Plot a hinton diagram for the quantum state.

Parameters

  • rho (ndarray) – Numpy array for state vector or density matrix.
  • title (str) – a string that represents the plot title
  • figsize (tuple) – Figure size in inches.
  • ax_real (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. If this is specified without an ax_imag only the real component plot will be generated. Additionally, if specified there will be no returned Figure since it is redundant.
  • ax_imag (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. If this is specified without an ax_imag only the real component plot will be generated. Additionally, if specified there will be no returned Figure since it is redundant.

Returns

The matplotlib.Figure of the visualization if neither ax_real or ax_imag is set.

Return type

matplotlib.Figure

Raises

ImportError – Requires matplotlib.

Example

from qiskit import QuantumCircuit, BasicAer, execute
from qiskit.visualization import plot_state_hinton
%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_hinton(job.get_statevector(qc), title="New Hinton Plot")

../_images/qiskit.visualization.plot_state_hinton_0_2.png ../_images/qiskit.visualization.plot_state_hinton_0_3.png

Was this page helpful?
Report a bug or request content on GitHub.