Skip to main content

Draw high-quality electrical circuit schematic diagrams with Schemdraw in Python

Here I will draw electrical circuit diagrams with Schemdraw in Python.

Schemdraw is a Python package for producing high-quality electrical circuit schematic diagrams. Circuit elements are added, one at a time, similar to how you might draw them by hand, using Python methods.

Installation
Schemdraw can be installed from pip using

pip install schemdraw

The schemdraw module "schemdraw.elements" is used for drawing circuit elements. It contains Basic Elements pre-defined for use in a drawing.

import schemdraw
import schemdraw.elements as elm

You can create with using a schemdraw.Drawing and add elements using 'add'method or '+=' poperator.

with schemdraw.Drawing() as d:
    d.add(elm.Resistor())
    d.add(elm.Capacitor())
    d += elm.Diode()

Save figure to a file. Using the with block the drawing is displayed and saved as exiting the with block. The filename is assgined by parameter file in schemdraw.Drawing() like file='my_circuit.svg'. The image type is determined from the file extension. Options include svg, eps, png, pdf, and jpg.

with schemdraw.Drawing(file='my_circuit.svg') as d:
    ...

Comments