# Qiskit plot_state_qsphere phase error

I'm trying to visualize a simple circuit in Qiskit. A single gate $$Y$$ is applied to the single-qubit register. The expected state is:

$$Y |0\rangle = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ i \end{bmatrix} = i |1\rangle$$

Then I visualize the final state with plot_state_qsphere function (documentation). Since the coefficient of $$|1\rangle$$ is $$i$$ I'm expecting phase $$\pi/2$$ since $$i = e^{i \pi/2}$$.

from qiskit import *
from qiskit.tools.visualization import plot_state_qsphere
print(qiskit.__qiskit_version__) # {'qiskit-terra': '0.15.1', 'qiskit-aer': '0.6.1', 'qiskit-ignis': '0.4.0', 'qiskit-ibmq-provider': '0.8.0', 'qiskit-aqua': '0.7.5', 'qiskit': '0.20.0'}
circuit = QuantumCircuit(1)
circuit.y(0)
statevector = execute(circuit, backend=Aer.get_backend('statevector_simulator')).result().get_statevector()
print(statevector) # [0.-0.j 0.+1.j]
plot_state_qsphere(statevector)


In this representation, $$\pi/2$$ phase corresponds to green color. However, I visualize the red color ($$0$$ phase). Is it a known bug? Am I missing something?

• There is an internal step that sets the phase of the largest component to one. Sep 6, 2020 at 17:47
• Thank you for your comment. Is there any way to avoid this behavior? Sep 6, 2020 at 19:01
• Not in Qiskit; you would have to modify the source code. An alternative is here: nonhermitian.org/kaleido/tutorials/interactive/qsphere.html Sep 7, 2020 at 13:16
• Thank you @PaulNation. If you want to add your comment as an answer, I'll accept it. Sep 7, 2020 at 14:09