Qiskit: Bloch Multi Vector

Bloch Multi Vector is useful for visualizing the state of all the Qubits of a Quantum Circuit. It produces bloch vector visualization for all the Qubits, and hence the name Bloch Multi Vector. Qiskit provides inbuilt function to create Bloch Multi Vector visualizations. In this chapter of the Qiskit Tutorial, you will learn about how to create Bloch Multi Vector visualization by making use of the visualization module of qiskit.

Bloch Multi Vector makes it possible to visualize the state of Qubits in the state of superposition, which gets destroyed upon measuring. This makes Bloch Multi Vector an excellent choice for visualizing the results from Statevector Simulator.

Importing Bloch Multi Vector Visualization Function

The plot_bloch_multivector() function of qiskit.visualization module creates a visualizations for the Qubit

from qiskit.visualization import plot_bloch_multivector()

Plotting Bloch Multi Vector

The plot_bloch_multivector() method accepts data for plotting Multiple Bloch Spheres as a Statevector or a Density Matrix.

Note– Unlike plot_bloch_vector(), plot_bloch_multivector() does not accept coordinates for plotting Bloch Vectors.

Example

In the following example, we will plot the following statevector on the Bloch Multi 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_bloch_multivector([0.5, 0.5, 0.5, 0.5])

The output of this will be-

Plotting Bloch Multi Vector visualizations
Plotting Bloch Multi Vector visualizations

Visualizing Statevector Simulator Results on Bloch Multi-Vector

In this section, we visualize the results from the Statevector Simulator using Bloch Multi-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 Bloch Multivector
plot_bloch_multivector(state_vec)

The output of this will be-

Plotting Bloch Multi Vector visualizations
Plotting Bloch Multi Vector visualizations

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_bloch_multivector() function.

Parameters

The following are some of the important parameters of the plot_bloch_multivector() function-

ParameterBrief Description
stateIt 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.
titleIt is a string that is used for the plot title.
reverse_bitsA boolean value that indicates whether the most significant Qubit/Bloch Sphere is to be in the left. Default is False. For example, if it is False, the least significant Qubit(Qubit 0) appears on the leftmost side.
figsizeA Tuple that contains the size of the figure in inches.
Parameters of the plot_bloch_multivector() function.