Skip to content
Pasqal Documentation

Drawing

Display a block, circuit, or quantum model.

The kwargs are forwarded to the underlying nx.Graph, so you can e.g. specify the size of the resulting plot via size="2,2" (see examples)

PARAMETER DESCRIPTION
x

AbstractBlock, QuantumCircuit, or QuantumModel.

TYPE: Any

qcd

Circuit diagram to plot the block into.

TYPE: QuantumCircuitDiagram | Cluster | None DEFAULT: None

layout

Can be either "LR" (left-right), or "TB" (top-bottom).

TYPE: str DEFAULT: 'LR'

theme

Available themes are: ["light", "dark", "black", "white"].

TYPE: str DEFAULT: 'light'

fill

Whether to fill the passed x with identities.

TYPE: bool DEFAULT: True

kwargs

Passed on to nx.Graph

TYPE: Any DEFAULT: {}

Examples:

from qadence import X, Y, kron
from qadence.draw import display
b = kron(X(0), Y(1))
display(b, size="1,1", theme="dark")
Source code in qadence/draw/__init__.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45def display(
x: Any,
qcd: QuantumCircuitDiagram | Cluster | None = None,
layout: str = "LR",
theme: str = "light",
fill: bool = True,
**kwargs: Any,
) -> Graph:
"""Display a block, circuit, or quantum model.
The `kwargs` are forwarded to
the underlying `nx.Graph`, so you can e.g. specify the size of the resulting plot via
`size="2,2"` (see examples)
Arguments:
x: `AbstractBlock`, `QuantumCircuit`, or `QuantumModel`.
qcd: Circuit diagram to plot the block into.
layout: Can be either "LR" (left-right), or "TB" (top-bottom).
theme: Available themes are: ["light", "dark", "black", "white"].
fill: Whether to fill the passed `x` with identities.
kwargs: Passed on to `nx.Graph`
Examples:
```python exec="on" source="material-block" html="1"
from qadence import X, Y, kron
from qadence.draw import display
b = kron(X(0), Y(1))
def display(*args, **kwargs): return args # markdown-exec: hide
display(b, size="1,1", theme="dark")
```
"""
return make_diagram(x, **kwargs).show()

Save a block, circuit, or quantum model to file. Accepts the same args/kwargs as display.

PARAMETER DESCRIPTION
x

AbstractBlock, QuantumCircuit, or QuantumModel.

TYPE: Any

filename

Should end in svg/png.

TYPE: str

args

Same as in display.

TYPE: Any DEFAULT: ()

kwargs

Same as in display.

TYPE: Any DEFAULT: {}

Examples:

from qadence import X, Y, kron
from qadence.draw import display
b = kron(X(0), Y(1))
savefig(b, "test.svg", size="1,1", theme="dark")
Source code in qadence/draw/__init__.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67def savefig(x: Any, filename: str, *args: Any, **kwargs: Any) -> None:
"""Save a block, circuit, or quantum model to file. Accepts the same args/kwargs as `display`.
Arguments:
x: `AbstractBlock`, `QuantumCircuit`, or `QuantumModel`.
filename: Should end in svg/png.
args: Same as in `display`.
kwargs: Same as in `display`.
Examples:
```python exec="on" source="material-block" html="1"
from qadence import X, Y, kron
from qadence.draw import display
b = kron(X(0), Y(1))
def savefig(*args, **kwargs): return args # markdown-exec: hide
savefig(b, "test.svg", size="1,1", theme="dark")
```
"""
make_diagram(x, *args, **kwargs).savefig(filename)