1
$\begingroup$

Executing

from qiskit import *
circuit = qiskit.QuantumCircuit(3, 3)
circuit.draw(output="mpl")

in ipython notebook gives the following image

circuit render

Which looks incomplete. It does not render two other classical registers and also appears to be incorrectly padded. Is my output image really incorrect? How can I fix that?

$\endgroup$
6
$\begingroup$

This is a known issue which was already fixed and will be released in the coming qiskit-terra 0.17.

from qiskit import *
circuit = qiskit.QuantumCircuit(3, 3)
circuit.draw(output="mpl")

enter image description here

$\endgroup$
2
  • $\begingroup$ Good to know. +1. Curious, when will qiskit moved from version 0. to 1.? Are you guys waiting for things to be more stable before changing it to 1.? Curious to know the timeline. $\endgroup$ – KAJ226 Mar 26 at 18:47
  • $\begingroup$ complicated subject. but yeap... mostly that. $\endgroup$ – luciano Mar 26 at 19:00
5
$\begingroup$

This looks alright to me, as you haven't added any gates to your circuit so there isn't anything else that should be displayed. As for the classical registers, they are all represent by the line at the bottom, the 3 shows that there are 3 classical registers. Setting cregbundle to false will draw them as independent lines, so circuit.draw(output="mpl", cregbundle=True).

$\endgroup$
2
$\begingroup$

@met927 looks great. Here is an another example on how you can define different classical register name and having them show up on different wire on your circuit:

qreg_q = QuantumRegister(2, 'qregister')
creg_c1 = ClassicalRegister(1, 'cregister1')
creg_c2 = ClassicalRegister(1, 'cregister2')

circuit = QuantumCircuit(qreg_q, creg_c1, creg_c2)
circuit.h(qreg_q[1])
circuit.cx(qreg_q[0], qreg_q[1])
circuit.measure(qreg_q[0], creg_c1[0])
circuit.measure(qreg_q[1], creg_c2[0])

circuit.draw( 'mpl',style={'name': 'bw'}, scale = 1)

This will give you something like:

enter image description here

$\endgroup$

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.