> For the complete documentation index, see [llms.txt](https://docs.zama.org/concrete/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zama.org/concrete/execution-analysis/other/formatting_and_drawing.md).

# Formatting and drawing

This document explains how to format and draw a compiled circuit in Python.

## Formatting

To convert your compiled circuit into its textual representation, use the `str` function:

```python
str(circuit)
```

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

```python
print(circuit)
```

{% hint style="warning" %}
Formatting is designed for debugging purpose only. It's not possible to create the circuit back from its textual representation. See [How to Deploy](/concrete/guides/deploy.md) if that's your goal.
{% endhint %}

## Drawing

{% hint style="danger" %}
Drawing functionality requires the installation of the package with the full feature set. See the [Installation](/concrete/get-started/installing.md) section for instructions.
{% endhint %}

To draw your compiled circuit, use the `draw` method:

```python
drawing = circuit.draw()
```

This method draws the circuit, saves it as a temporary PNG file and returns the file path.

You can display the drawing in a Jupyter notebook:

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

Alternatively, you can use the `show` option of the `draw` method to display the drawing with `matplotlib`:

```python
circuit.draw(show=True)
```

{% hint style="danger" %}
Using this option will clear any existing matplotlib plots.
{% endhint %}

Lastly, to save the drawing to a specific path, use the `save_to` option:

```python
destination = "/tmp/path/of/your/choice.png"
drawing = circuit.draw(save_to=destination)
assert drawing == destination
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zama.org/concrete/execution-analysis/other/formatting_and_drawing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
