Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.1k stars 2.34k forks source link

Vertical Circuit Drawings #12169

Open AlexanderGroeger opened 5 months ago

AlexanderGroeger commented 5 months ago

What should we add?

What to add Add a vertical keyword argument to the QuantumCircuit.draw method

What does it do? Plot the circuit vertically with the circuit starting at the top of the plot and ending at bottom.

What's the use case? Drawing deep quantum circuits often extend off the screen and wrap onto a "newline" which can be clunky to follow. Many Qiskit developers use Jupyter notebooks that scroll vertically, thus plotting circuits vertically would yield better visualization flow on a notebook or figure in a paper.

jwalaQ commented 5 months ago

Hi Alexander, Wondering whether a scrollable horizontal orientation would also suit your use-case, i.e. scrollable horizontal orientation rather than vertical 🤔.

Or perhaps either would be an improvement on the current behavior 🤷‍♂️. Would like to work on this issue. Let me know your thoughts.

jwalaQ commented 5 months ago

Just noticed there's an argument fold within the QuantumCircuit.draw() method which controls pagination of the output.

The entire circuit can be displayed in a single row if set to fold = -1. The image becomes tiny but can be zoomed into, maintaining the original quality.

Nonetheless, the feature request stands.

AlexanderGroeger commented 5 months ago

Hello Prajjwal,

Thank you for looking at my feature request. I'm delighted to hear you have interest in working on this issue. A scrollable horizontal plot would be low hanging fruit. I think it would be a good first step, perhaps it's already been done. I imagine if you use fold=-1 and something like figsize=(80,10), you could easily get a really wide figure which might be scrollable horizontally already.

I think the deep circuit paper figures use case is the only realistic reasoning for having a vertical layout because you may be able to fit your circuit better vertically than horizontally, nevertheless I think a vertical layout would be cool if there's interest for it.