54 lines
2.6 KiB
Plaintext
54 lines
2.6 KiB
Plaintext
---
|
||
title: plot_state_hinton
|
||
description: API reference for qiskit.visualization.plot_state_hinton
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: function
|
||
python_api_name: qiskit.visualization.plot_state_hinton
|
||
---
|
||
|
||
# qiskit.visualization.plot\_state\_hinton
|
||
|
||
<Function id="qiskit.visualization.plot_state_hinton" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.17/qiskit/visualization/state_visualization.py" signature="plot_state_hinton(state, title='', figsize=None, ax_real=None, ax_imag=None, *, rho=None)">
|
||
Plot a hinton diagram for the density matrix of a quantum state.
|
||
|
||
**Parameters**
|
||
|
||
* **state** ([*Statevector*](qiskit.quantum_info.Statevector "qiskit.quantum_info.Statevector") *or*[*DensityMatrix*](qiskit.quantum_info.DensityMatrix "qiskit.quantum_info.DensityMatrix") *or ndarray*) – An N-qubit quantum state.
|
||
* **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.
|
||
* [**VisualizationError**](qiskit.visualization.VisualizationError "qiskit.visualization.VisualizationError") – if input is not a valid N-qubit state.
|
||
|
||
**Example**
|
||
|
||
```python
|
||
from qiskit import QuantumCircuit
|
||
from qiskit.quantum_info import DensityMatrix
|
||
from qiskit.visualization import plot_state_hinton
|
||
%matplotlib inline
|
||
|
||
qc = QuantumCircuit(2)
|
||
qc.h(0)
|
||
qc.cx(0, 1)
|
||
|
||
state = DensityMatrix.from_instruction(qc)
|
||
plot_state_hinton(state, title="New Hinton Plot")
|
||
```
|
||
|
||
 
|
||
</Function>
|
||
|