Pauli Vector Visualization is used to represent a state matrix over the Pauli Matrices. Qiskit provides inbuilt function to create Pauli Vector visualizations. In this chapter of the Qiskit Tutorial, you will learn about how to create Pauli Vector visualizations by making use of the visualization module of qiskit.
Pauli Vector creates a sparse bar graph representation of various expectation values over the Pauli Matrices. Pauli Vector is also useful for visualizing mixed states. The height of the bar is representative of the expectation values in the range of -1.0 to 1.0
Importing Pauli Vector Visualization Function
The plot_state_paulivec()
function of qiskit.visualization
module creates a visualizations for the Qubit
from qiskit.visualization import plot_state_paulivec()
Plotting Pauli Vector
The plot_state_paulivec()
method accepts data for plotting Pauli Vector as a Statevector or a Density Matrix.
Example
In the following example, we will plot the following statevector on the Pauli Vector –
[0.5 0.5 0.5 0.5]
which represents the state: ψ = 0.5 |00> + 0.5 |01> + 0.5 |10> + 0.5 |11>
plot_state_paulivec([0.5, 0.5, 0.5, 0.5])
The output of this will be-
Note– Notice that the representation of the Pauli Vector is a sparse bar graph over the Pauli Matrices.
Visualizing Statevector Simulator Results on Pauli Vector
In this section, we visualize the results from the Statevector Simulator using a Pauli Vector.
# Creating a Quantum Circuit to run on the Statevector Simulator
qc=QuantumCircuit(2)
# Applying H Gate to both Qubits
qc.h([0,1])
# Setting Backend to Statevector Simulator
backend = BasicAer.get_backend('statevector_simulator')
# Executing the Quantum Circuit
job=execute(qc, backend)
#Get results from job
result = job.result()
# Getting the count of various measurement states
state_vec = result.get_statevector()
# Plotting Pauli Vector
plot_state_paulivec(state_vec)
The output of this will be-
Note– The get_statevector()
method returns the statevector in the form of a numpy array. Therefore, state_vec
variable can be passed directly to the plot_state_paulivec()
function.
Parameters
The following are some of the important parameters of the plot_state_paulivec()
function-
Parameter | Brief Description |
---|---|
state | It is a Statevector or a Density Matrix that represents the state of all Qubits in the Quantum Circuit. It is usually passed as a positional parameter. |
title | It is a string that is used for the plot title. |
color | A string or a list of strings that contains the color of the bars. |
figsize | A Tuple that contains the size of the figure in inches. |