Formatting and drawing

Formatting

You can convert your compiled circuit into its textual representation by converting it to string:

str(circuit)

If you just want to see the output on your terminal, you can directly print it as well:

print(circuit)
circle-exclamation

Drawing

triangle-exclamation

You can use the draw method of your compiled circuit to draw it:

drawing = circuit.draw()

This method will draw the circuit on a temporary PNG file and return the path to this file.

You can show the drawing in a Jupyter notebook, like this:

from PIL import Image
drawing = Image.open(circuit.draw())
drawing.show()
drawing.close()

Or, you can use the show option of the draw method to show the drawing with matplotlib.

triangle-exclamation

Lastly, you can save the drawing to a specific path:

Last updated

Was this helpful?