# Qiskit's draw method is moves the gates on the qubit wires

Well,it is not very important problem and I actually did what I wanted but I just noticed that when I want to draw circuit, qiskit draw method is not drawing the circuit with the correct order.. I wonder if there is a specific reason for it and I don't know it, or did I miss something or it is really not drawing....

Here is my circuit:

Here is my qiskit code:

qc_AB = QuantumCircuit(3)
qc_AB.h(2)
qc_AB.cx(1,2)
qc_AB.tdg(2)
qc_AB.cx(0,2)
qc_AB.t(2)
qc_AB.cx(1,2)
qc_AB.tdg(2)
qc_AB.cx(0,2)
qc_AB.t(1)
qc_AB.t(2)
qc_AB.cx(0,1)
qc_AB.h(2)
qc_AB.t(0)
qc_AB.tdg(1)
qc_AB.cx(0,1)
qc_AB.draw()


And here is what qiskit draw fucntion showed me:

It's still the same circuit -- but the circuit drawer shows the gates "as soon as possible", which means it'll move them to the left if possible. In your example, you'll notice that the drawer moved the last T gate on the wire of q_1 further to the left, through the CX gate.

As this example shows, the common circuit representation is not unique! That's why Qiskit (and other packages) use a directed, acyclic Graph (DAG) representation of the circuit which doesn't have this problem.

As @Cryoris said in his answer, it's still the same circuit. However, if you want the circuit plot to have the same gate alignment, there is a simple trick to do that:

1. Add a barrier before the t-gates.
2. Set the draw method's option plot_barriers to False.
qc_AB = QuantumCircuit(3)
qc_AB.h(2)
qc_AB.cx(1,2)
qc_AB.tdg(2)
qc_AB.cx(0,2)
qc_AB.t(2)
qc_AB.cx(1,2)
qc_AB.tdg(2)
qc_AB.cx(0,2)
qc_AB.barrier() # <=== (1)
qc_AB.t(1)
qc_AB.t(2)
qc_AB.cx(0,1)
qc_AB.h(2)
qc_AB.t(0)
qc_AB.tdg(1)
qc_AB.cx(0,1)
qc_AB.draw(plot_barriers = False) # <=== (2)


The result will looks like:

                                                             ┌───┐
q_0: ───────────────────■─────────────────────■──────────■───┤ T ├───■──
│                     │   ┌───┐┌─┴─┐┌┴───┴┐┌─┴─┐
q_1: ───────■───────────┼─────────■───────────┼───┤ T ├┤ X ├┤ Tdg ├┤ X ├
┌───┐┌─┴─┐┌─────┐┌─┴─┐┌───┐┌─┴─┐┌─────┐┌─┴─┐ ├───┤├───┤└─────┘└───┘
q_2: ┤ H ├┤ X ├┤ Tdg ├┤ X ├┤ T ├┤ X ├┤ Tdg ├┤ X ├─┤ T ├┤ H ├────────────
└───┘└───┘└─────┘└───┘└───┘└───┘└─────┘└───┘ └───┘└───┘