Matplotlib#

class discopy.drawing.backend.Matplotlib(axis=None, figsize=None, linewidth=1, format=None)[source]#

Bases: Backend

Matplotlib drawing backend.

dark_gid(kind)[source]#

A fresh id prefixed dark-stroke or dark-fill, tagging an element drawn black on the neutral canvas so that DARK_MODE_STYLE turns it white on a dark page.

draw_region_cell(left, right, facecolor)[source]#

Fill the cell between two quadratic Beziers with a single patch: down the left boundary, straight across the bottom, up the right boundary and straight back across the top. Antialiasing is disabled so that abutting cells of the same colour do not leave a hairline seam where the background shows through.

draw_regions(graph, **params)[source]#

Fill the coloured 0-cell regions of the diagram, one patch per cell of region_cells().

draw_legend(graph, **params)[source]#

Add a legend mapping each region colour to its label.

draw_spiders(graph, draw_box_labels=True, **params)[source]#

Draws the spiders, grouped by shape and by whether they adapt to a dark page: black spiders lie on the neutral canvas so they turn white, coloured ones keep their colour. A transparent spider is just its label, e.g. the symbol of an discopy.monoidal.Equation, which leaves no patch on a coloured page.