qml.drawer

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

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

def

Developer Methods

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

Functions

convert_wire_order(ops[, wire_order, …])

Creates the mapping between wire labels and place in order.

drawable_grid(ops[, wire_map])

Determine non-overlapping yet dense placement of operations for drawing.

drawable_layers(ops[, wire_map])

Determine non-overlapping yet dense placement of operations into layers for drawing.

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

Produces a matplotlib graphic from a tape.

Classes

CircuitDrawer(raw_operation_grid, …[, …])

Creates a circuit diagram from the operators of a CircuitGraph in grid form.

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

Allows easy creation of graphics representing circuits with matplotlib