TransWikia.com

Change the position of a gate in Qiskit for better representation

Quantum Computing Asked by A. Jahin on October 7, 2020

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?

One Answer

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

Correct answer by luciano on October 7, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP