2
$\begingroup$

I'm using Qiskit to demonstrate some circuits, and I want to change the position of some gates for better representation.

For example, look at this circuit: enter image description here

I'd like for the last $R_x(\frac{-\pi}{2})$ to align with the last Hadamard gate. Is there a way to do this without using barriers?

$\endgroup$
2
$\begingroup$

The justify= parameter might help.

qc.draw('mpl', reverse_bits=True, justify='right')

enter image description here

Other option is to add the barrier and then remove them from the plot (though that will skip all the barriers)

...
qc.barrier(range(4))
qc.h(3)
qc.rx(-pi/2, 0)
qc.draw('mpl', reverse_bits=True, plot_barriers=False)

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ The adding barrier then removing it seems like a good solution. Thanks a lot! $\endgroup$ – A. Jahin Sep 26 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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