# Can't draw figures with Qiskit in Visual Studio

I'm using Qiskit in Visual Studio 2019. I want to draw quantum circuits, but it only shows their sizes with text instead of figures. The output on the interactive window is like this.

>>> from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
...: import numpy as np
...: %matplotlib inline

In [2]: qr = QuantumRegister(1)
...: cr = ClassicalRegister(1)
...: circuit = QuantumCircuit(qr, cr)
...: circuit.h(qr[0])
Out [2]: <qiskit.extensions.standard.h.HGate at 0x2c9b16b8e80>

In [3]: circuit.draw(output="mpl")
Out [3]: <Figure size 240.8x138.46 with 1 Axes>


Is there any way to draw circuits correctly, or is it simply that Qiskit doesn't work in Visual Studio?

<edited> the qiskit version

In [6]: print(qiskit.__version__)
0.8.1

• For me it works in the separate terminal in visual studio (on wsl) not in the interactive window. Do you know the version? print(qiskit.__version__) – Bram Jun 6 '19 at 11:56

## 1 Answer

If you are in the interactive window, it probably works similarly to Jupyter Notebooks. I would run %matplotlib inline, and then try calling circuit.draw(output='mpl') again.

You could also try running the line circuit.draw(output='mpl') twice, as that also will render the Figure in Jupyter Notebookes.

• I don't understand what you mean. Is that running# import anything I need<br/> # define the circuit<br/> %matplotlib inline<br/> circuit.draw(output='mpl') and # import anything I need<br/> # define the circuit<br/> circuit.draw(output='mpl')<br/> circuit.draw(output='mpl')? Neither work for me. – Lemonade Jun 11 '19 at 10:43
• How do I start a new line btw? It looks awful without any. – Lemonade Jun 11 '19 at 10:52
• My answer is assuming that the interactive window in Visual Studios works similar to coding in Jupyter Notebooks. Example code of what I meant is: %matplotlib inline import qiskit from qiskit import QuantumCircuit qc = QuantumCircuit(5, 5) qc.draw(output='mpl') This is the most basic example without any gates, but it should still render the empty circuit Figure – Matthew Stypulkoski Jun 11 '19 at 13:42
• Also not sure about starting new lines. Each of those code blocks is a separate line though. – Matthew Stypulkoski Jun 11 '19 at 13:46
• Still not working. But I found I can draw figures in Jupyter Notebooks, so it might be better using Jupyter Notebooks. – Lemonade Jun 17 '19 at 3:58