Getting 'Figure(..x..)' when drawing quantum circuit with qiskit “mpl” output mode

Viewed 193

I am just starting with Quantum Computing and I tried the following code.

from qiskit import *

qr = QuantumRegister(2)
cr = ClassicalRegister(2)

Qc = QuantumCircuit(qr,cr)

print ('This is the initial state')
print(Qc.draw(output = 'mpl'))
print ('')

The problem I am facing is with drawing the circuit. When use qc.draw() it gives me a line representation of the circuit and its good enough for me to see what is on it. But when I put output='mpl' I am getting the following results.

This results in

This is the initial state
Figure(142.949x204.68)

I have been using spyder for all my programming but I also tried the same thing in jupyter and the result was the same. What is this Figure(.............) and where can I find it?

2 Answers

When you use 'mpl', the output is a figure and not a string that you can print. Remove print and try:

print ('This is the initial state')
Qc.draw('mpl').show()

The output is:

This is the initial state

output

Hey I tried this with a simple change in the draw command

from qiskit import *

qr = QuantumRegister(2)
cr = ClassicalRegister(2)

Qc = QuantumCircuit(qr,cr)

print ('This is the initial state')
Qc.draw(output = 'mpl')

Output:

enter image description here

If this didn't work try installing visualization tools

Related