Drawing
Drawing
Section titled “Drawing”
display(x, qcd=None, layout='LR', theme='light', fill=True, **kwargs)
Section titled “
display(x, qcd=None, layout='LR', theme='light', fill=True, **kwargs)
”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
|
TYPE:
|
qcd
|
Circuit diagram to plot the block into.
TYPE:
|
layout
|
Can be either "LR" (left-right), or "TB" (top-bottom).
TYPE:
|
theme
|
Available themes are: ["light", "dark", "black", "white"].
TYPE:
|
fill
|
Whether to fill the passed
TYPE:
|
kwargs
|
Passed on to
TYPE:
|
Examples:
from qadence import X, Y, kronfrom qadence.draw import display
b = kron(X(0), Y(1))display(b, size="1,1", theme="dark")Source code in qadence/draw/__init__.py
131415161718192021222324252627282930313233343536373839404142434445def 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()
savefig(x, filename, *args, **kwargs)
Section titled “
savefig(x, filename, *args, **kwargs)
”Save a block, circuit, or quantum model to file. Accepts the same args/kwargs as display.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
TYPE:
|
filename
|
Should end in svg/png.
TYPE:
|
args
|
Same as in
TYPE:
|
kwargs
|
Same as in
TYPE:
|
Examples:
from qadence import X, Y, kronfrom 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
4849505152535455565758596061626364656667def 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)