5
$\begingroup$

Trying to plot the Bloch Sphere of the IBM Qiskit logo

from qiskit import execute, Aer, IBMQ, QuantumCircuit
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_state_qsphere, plot_bloch_multivector
%matplotlib inline

# no. of qubits
n = 4

# create circuit
qc = QuantumCircuit(n)

# apply hadamard
qc.h(0)

# apply cnot
for i in range(n-1):
    qc.cx(0, i+1)

# apply not on q1
qc.x(1)

# get state vector
sv = Statevector.from_instruction(qc).data

# plots
plot_state_qsphere(sv)
plot_bloch_multivector(sv)

enter image description here

Why the Bloch Sphere does not have any state representations?

Circuit link

$\endgroup$
4
  • 1
    $\begingroup$ The logo is a Qsphere not a Bloch sphere. The former is a multi Qubit statevector visualization whereas the latter is for single qubits. $\endgroup$ Commented Mar 28, 2021 at 13:35
  • $\begingroup$ @PaulNation Thanks. plot_bloch_multivector is for visualizing the individual qubits. It works for other circuits. What am I missing here? $\endgroup$
    – Van Peer
    Commented Mar 28, 2021 at 13:37
  • 2
    $\begingroup$ If each qubit is maximally entangled with the others then the bloch cector has zero length. Try a bell state for example. $\endgroup$ Commented Mar 28, 2021 at 13:39
  • $\begingroup$ @PaulNation that explains it! Cheers!! $\endgroup$
    – Van Peer
    Commented Mar 28, 2021 at 13:46

2 Answers 2

4
$\begingroup$

As @PaulNation explained, the bloch spheres represent maximally entangled qubits as zero-length vectors. Hence, no arrows.

The Qiskit logo is a qsphere of a particular statevector. In particular, a 6-qubit state, according to Abe:

from qiskit.visualization import plot_state_qsphere
state = [0]*2**6
state[2] = 1; state[61] = 1
plot_state_qsphere(state, show_state_labels=False)

qiskit logo qsphere

So... you are actually really really close. Just change n = 6 I you will get it!

Here is your fixed code:

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

n = 6
qc = QuantumCircuit(n)
qc.h(0)
for i in range(n-1):
    qc.cx(0, i+1)
qc.x(1)

sv = Statevector.from_instruction(qc)
plot_state_qsphere(sv, show_state_labels=False)

qiskit logo qsphere

To increase the similarity, delete the legend and modify the elevation:

fig = plot_state_qsphere(sv, show_state_labels=False)
fig.axes[0].view_init(elev=11, azim=275)
fig.axes[1].set_visible(False)
fig

enter image description here

$\endgroup$
1
  • $\begingroup$ do qiskit logo have any special meaning, where is it come from? $\endgroup$
    – poig
    Commented Jul 14, 2022 at 18:16
-1
$\begingroup$

Apply these gates in order:

circuit=QuantumCircuit(4)
circuit.h(1)
circuit.cx(1,0)
circuit.cx(1,2)
circuit.cx(1,3)
circuit.x(1)
$\endgroup$

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.