drawing.MatBackend

class rewalt.drawing.MatBackend(**params)

Bases: DrawBackend

Drawing backend outputting Matplotlib figures.

Methods

draw_arrow(xy0, xy1, **params)

Draws an arrow on the canvas.

draw_label(label, xy, offset, **params)

Draws a label next to a location on the canvas.

draw_node(xy, **params)

Draws a node on the canvas.

draw_wire(wire_xy, node_xy, **params)

Draws a wire from a wire vertex to a node vertex on the canvas.

output(**params)

Output the picture.

draw_wire(wire_xy, node_xy, **params)

Draws a wire from a wire vertex to a node vertex on the canvas.

Parameters
  • wire_xy (tuple[float]) – The coordinates of the wire vertex.

  • node_xy (tuple[float]) – The coordinates of the node vertex.

Keyword Arguments
  • color (multiple types) – The colour of the wire (default is self.fgcolor).

  • alpha (float) – Alpha factor of the wire (default is 1).

  • depth (bool) – Whether to draw the wire with a contour, to simulate “crossing over” objects that are already on the canvas (default is True).

draw_label(label, xy, offset, **params)

Draws a label next to a location on the canvas.

Parameters
  • label (str) – The label.

  • xy (tuple[float]) – The coordinates of the object to be labelled.

  • offset (tuple[float]) – Point offset of the label relative to the object.

Keyword Arguments

color (multiple types) – The colour of the label (default is self.fgcolor).

draw_node(xy, **params)

Draws a node on the canvas.

Parameters

xy (tuple[float]) – The coordinates of the node.

Keyword Arguments
  • color (multiple types) – Fill colour of the node (default is self.fgcolor).

  • stroke (multiple types) – Stroke colour of the node (default is same as color).

draw_arrow(xy0, xy1, **params)

Draws an arrow on the canvas.

Parameters
  • xy0 (tuple[float]) – The coordinates of the starting point.

  • xy1 (tuple[float]) – The coordinates of the ending point.

Keyword Arguments
  • color (multiple types) – Colour of the arrow (default is self.fgcolor).

  • shorten (float) – Factor by which to scale the length (default is 1).

output(**params)

Output the picture.

Keyword Arguments
  • show (bool) – Whether to show the output (default is True).

  • path (str) – Path where to save the output (default is None).

  • scale (float) – (TikZ only) Scale factor to apply to output (default is 3).

  • xscale (float) – (TikZ only) Scale factor to apply to x axis in output (default is same as scale)

  • yscale (float) – (TikZ only) Scale factor to apply to y axis in output (default is same as scale)