class schemdraw.Drawing(*elements: schemdraw.elements.elements.Element, unit: Optional[float] = None, inches_per_unit: Optional[float] = None, lblofst: Optional[float] = None, fontsize: Optional[float] = None, font: Optional[str] = None, color: Optional[str] = None, lw: Optional[float] = None, ls: Optional[Literal[-, :, --, -.]] = None, fill: Optional[str] = None)

A schematic drawing

See schemdraw.config method for argument defaults

  • *elements – List of Element instances to add to the drawing

  • unit – Full length of a 2-terminal element. Inner zig-zag portion of a resistor is 1.0 units.

  • inches_per_unit – Inches per drawing unit for setting drawing scale

  • lblofst – Default offset between element and its label

  • fontsize – Default font size for text labels

  • font – Default font family for text labels

  • color – Default color name or RGB (0-1) tuple

  • lw – Default line width for elements

  • ls – Default line style

  • fill – Deault fill color for closed elements


(xy tuple) Current drawing position. The next element will be added at this position unless specified otherwise.


(float) Current drawing angle, in degrees. The next element will be added with this angle unless specified otherwise.

add(element: Element | Type[Element], **kwargs)Element

Add an element to the drawing.


element – The element to add.

add_elements(*elements: schemdraw.elements.elements.Element)None

Add multiple elements to the drawing

draw(showframe: bool = False, show: bool = True, ax=None, backend: Optional[Literal[svg, matplotlib]] = None)

Draw the schematic

  • showframe – Show axis frame. Useful for debugging a drawing.

  • show – Show the schematic in a GUI popup window (when outside of a Jupyter inline environment)

  • ax – Existing axis to draw on. Should be set to equal aspect for best results.


schemdraw Figure object


Get drawing bounding box

get_imagedata(fmt: ImageFormat | ImageType)bytes

Get image data as bytes array


fmt – Format or file extension of the image type


Image data as bytes

get_segments()list[Segment | SegmentText | SegmentArc | SegmentArrow | SegmentCircle | SegmentPoly]

Get flattened list of all segments in the drawing

interactive(interactive: bool = True)

Enable interactive mode (matplotlib backend only). Matplotlib must also be set to interactive with plt.ion().

move(dx: float, dy: float)None

Move the current drawing position

  • dx – change in x position

  • dy – change in y position


Pop/load the drawing state. Location and angle are returned to previously pushed state.


Push/save the drawing state. Drawing.here and Drawing.theta are saved.

save(fname: str, transparent: bool = True, dpi: float = 72)None

Save figure to a file

  • fname – Filename to save. File type automatically determined from extension (png, svg, jpg)

  • transparent – Save as transparent background, if available

  • dpi – Dots-per-inch for raster formats


Removes previously added element


class schemdraw.elements.Element(*d, **kwargs)

Standard circuit element.

Keyword Arguments are equivalent to calling setter methods.


d – Drawing direction (‘up’, ‘down’, ‘left’, ‘right’)


Dictionary of anchor positions in element coordinates


Dictionary of anchor positions in absolute drawing coordinates


List of drawing primitives making up the element


Transformation from element to drawing coordinates

Anchor names are dynmically added as attributes after placing the element in a Drawing.

anchor(anchor: str)Element

Specify anchor for placement. The anchor will be aligned with the position specified by at() method.

at(xy: XY | tuple[Element, str])Element

Set the element xy position


xy – (x,y) position or tuple of (Element, anchorname)

color(color: str)Element

Sets the element color


color – color name or hex value (ie ‘#FFFFFF’)


Set the direction to down

fill(color: bool | str = True)Element

Sets the element fill color.

  • color – Color string name or hex value, or

  • to fill with the element line color. (True) –


Apply flip up/down

get_bbox(transform=False, includetext=True)

Get element bounding box

  • transform – Apply the element transform to the bbox to get bounds in Drawing coordinates

  • includetext – Consider text when calculating bounding box. Text width and height can vary by font, so this produces an estimate of bounds.


Corners of the bounding box, (xmin, ymin, xmax, ymax)


Do not move the Drawing here position after placing this element

label(label: str | Sequence[str], loc: LabelLoc = None, ofst: XY | float | None = None, halign: Halign = None, valign: Valign = None, rotate: bool | float = False, fontsize: float = None, font: str = None, color: str = None)

Add a label to the Element.

  • label – The text string or list of strings. If list, each string will be evenly spaced along the element (e.g. [‘-‘, ‘V’, ‘+’])

  • loc – Label position within the Element. Either (‘top’, ‘bottom’, ‘left’, ‘right’), or the name of an anchor within the Element.

  • ofst – Offset from default label position

  • halign – Horizontal text alignment (‘center’, ‘left’, ‘right’)

  • valign – Vertical text alignment (‘center’, ‘top’, ‘bottom’)

  • rotate – True to rotate label with element, or specify rotation angle in degrees

  • fontsize – Size of label font

  • font – Name/font-family of label

  • color – Color of label


Set the direction to left

linestyle(ls: Literal[-, :, --, -.])Element

Sets the element line style


ls – Line style (‘-‘, ‘:’, ‘–’, ‘-.’).

linewidth(lw: float)Element

Sets the element line width


lw – Line width


Apply reverse left/right


Set the direction to right

scale(scale: float = 1)Element

Apply scale/zoom factor to element

style(color: Optional[str] = None, fill: Optional[str] = None, ls: Optional[Literal[-, :, --, -.]] = None, lw: Optional[float] = None)Element

Apply all style parameters

  • color – Color string or hex value

  • fill – Color string or hex

  • ls – Line style (‘-‘, ‘:’, ‘–’, ‘-.’)

  • lw – Line width

theta(theta: float)Element

Set the drawing direction angle in degrees


Set the direction to up

zorder(zorder: int)Element

Sets the element zorder. Higher zorders will be drawn above lower zorder elements.


class schemdraw.elements.Element2Term(*d, **kwargs)

Two terminal element. The element leads can be automatically extended to the start and ending positions.

  • start

  • center

  • end

endpoints(start: Union[Sequence[float], schemdraw.util.Point], end: Union[Sequence[float], schemdraw.util.Point])Element2Term

Sets absolute endpoints of element

length(length: float)Element2Term

Sets total length of element

to(xy: Union[Sequence[float], schemdraw.util.Point])Element2Term

Sets ending position of element

tox(x: float | XY | Element)Element2Term

Sets ending x-position of element (for horizontal elements)

toy(y: float | XY | Element)Element2Term

Sets ending y-position of element (for vertical elements)


class schemdraw.elements.ElementDrawing(drawing, **kwargs)

Create an element from a Drawing


drawing – The Drawing instance to convert to an element

Element Style


Set global element style


style – dictionary of {elementname: Element} to change the element module namespace. Use elements.STYLE_US or elements.STYLE_IEC to define U.S. or European/IEC element styles.