1

I'm trying to make my circuit look readable, but the gates auto-order in Qiskit QuantumCircuit shifts all gates to the left side. For example an image from qiskit documentation:

image

It would be much better to put ancilla X gate into the first column, Hadamard gats into the second, controlled gates into the third-fourth-fifth, and last Hadamard into the sixth column.

Such a result may be achieved in Quirk quirkAnalogue

Is there a way to set up an explicit column number for the quantum gate in the Qiskit QuantumCircuit (or other class)?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Oxoron
  • 664
  • 1
  • 7
  • 26

1 Answers1

1

You can use barriers to align the gates:

from qiskit import QuantumCircuit
circuit = QuantumCircuit(4)
circuit.x(3)
circuit.barrier()
circuit.h(range(4))
circuit.cx([0,1,2], 3)
circuit.h(range(3))
circuit.measure_all()
circuit.draw('mpl')

circuit with barriers

If you want to remove them from the plot:

circuit.draw('mpl', plot_barriers=False)

same circuit, aligned, no barriers showed

luciano
  • 399
  • 4
  • 13