qml.drawer

The drawer module contains the code for generating visuals of circuits.

This module provides the circuit drawing functionality used to display circuits visually.

Functions

draw(qnode[, wire_order, show_all_wires, …])

Create a function that draws the given qnode.

draw_mpl(qnode[, wire_order, …])

Draw a qnode with matplotlib

tape_mpl(tape[, wire_order, show_all_wires, …])

Produces a matplotlib graphic from a tape.

tape_text(tape[, wire_order, …])

Text based diagram for a Quantum Tape.

Classes

MPLDrawer(n_layers, n_wires[, wire_options, …])

Allows easy creation of graphics representing circuits with matplotlib

Styling Matplotlib Circuit Graphics

The drawer module provides two functions for modifying the style of matplotlib graphics, such as those generated by qml.draw_mpl. The qml.drawer.use_style function modifies the plt.rcParams global styling variable. Any styling can be reset with qml.drawer.use_style('default') or plt.style.use('default').

available_styles()

Get available style specification strings.

use_style(style)

Set a style setting.

The following images are generated via the code:

@qml.qnode(qml.device('lightning.qubit', wires=(0,1,2,3)))
def circuit(x, z):
    qml.QFT(wires=(0,1,2,3))
    qml.Toffoli(wires=(0,1,2))
    qml.CSWAP(wires=(0,2,3))
    qml.RX(x, wires=0)
    qml.CRZ(z, wires=(3,0))
    return qml.expval(qml.PauliZ(0))

qml.drawer.use_style(style)
fig, ax = qml.draw_mpl(circuit)(1.2345, 1.2345)

Currently Available Styles

bws

bwd

sol

sod

def