Bengali
Languages
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

qiskit.visualization.plot_state_paulivec

plot_state_paulivec(state, title='', figsize=None, color=None, ax=None, *, rho=None, filename=None)[source]

Plot the paulivec representation of a quantum state.

Plot a bargraph of the density matrix of a quantum state using as a basis all possible tensor products of Pauli operators and identities, that is, \(\{\bigotimes_{i=0}^{N-1}P_i\}_{P_i\in \{I,X,Y,Z\}}\), where \(N\) is the number of qubits.

0.15.1 ভার্সন থেকে ডেপ্রিকেটেড: qiskit.visualization.state_visualization.plot_state_paulivec()'s argument rho is deprecated as of qiskit-terra 0.15.1. It will be removed no earlier than 3 months after the release date. Instead, use the argument state, which behaves identically.

প্যারামিটার
  • state (Statevector or DensityMatrix or ndarray) -- an N-qubit quantum state.

  • title (str) -- a string that represents the plot title

  • figsize (tuple) -- Figure size in inches.

  • color (list or str) -- Color of the coefficient value bars.

  • 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.

রিটার্নস

The matplotlib.Figure of the visualization if the ax kwarg is not set

রিটার্ন টাইপ

matplotlib.Figure

রেইজেস
  • MissingOptionalLibraryError -- Requires matplotlib.

  • VisualizationError -- if input is not a valid N-qubit state.

Examples

# You can set a color for all the bars.

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_state_paulivec

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

state = Statevector(qc)
plot_state_paulivec(state, color='midnightblue', title="New PauliVec plot")

(Source code)

../_images/qiskit-visualization-plot_state_paulivec-1.png
# If you introduce a list with less colors than bars, the color of the bars will
# alternate following the sequence from the list.

import numpy as np
from qiskit.quantum_info import DensityMatrix
from qiskit import QuantumCircuit
from qiskit.visualization import plot_state_paulivec

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

qc = QuantumCircuit(2)
qc.h([0, 1])
qc.cz(0, 1)
qc.ry(np.pi/3, 0)
qc.rx(np.pi/5, 1)

matrix = DensityMatrix(qc)
plot_state_paulivec(matrix, color=['crimson', 'midnightblue', 'seagreen'])

(Source code)

../_images/qiskit-visualization-plot_state_paulivec-2.png