I'd like to get a statevector result through Result.get_statevector in Qiskit. However, since my circuit has too many qubits(13qubits) to represent the whole statevector results at a time, I'm searching how I can see the skipped results.

For example,


job= execute(circuit, simulator)
result = job.result()

job_result = result.get_statevector(circuit)

after such code I could see the result like,

[ 0.0221-0.j 0.0221-0.j 0.0221-0.j ... -0. -0.j -0. -0.j 0. +0.j]

Is there any way to see these omitted results or to handle 'qiskit_aer.backends.compatibility.Statevector' class?


2 Answers 2


If you really want to look at the numerical complex value of each single amplitude in the statevector, you can use something like the following:

from qiskit.quantum_info import Statevector
from qiskit.visualization import array_to_latex

num_qubits = 13
qc = circuit.remove_final_measurements(inplace=False)
array_to_latex(Statevector(qc), max_size=2**num_qubits)

Note that you have to remove all the final measurements (if present) to create the Statevector object without errors.

However, this is likely to crash because $2^{13} = 8192$ may be already too many complex numbers to be visualized properly. What you could do instead, is to fill an histogram by using the probabilities vector $p = \left( \left | \alpha_1 \right |^2, \left | \alpha_2 \right |^2,\dots, \left | \alpha_{2^n} \right |^2 \right)$, where $\alpha_i$ is the $i$-th amplitude in your $n$-qubits statevector. This histogram can be easily created in matplotlib by the following code:

import pylab as plt
x = range(2**num_qubits)
p = Statevector(qc).probabilities()
plt.bar(x=x, height=p)

You can simply use the Statevector's draw() method:

job_result.draw('latex', max_size = 32)

where, job_result is the variable in your code.

This way, you get a nice-looking output, and you can control the number of displayed components via max_size parameter.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.