Drawing schematics in pythonΒΆ

An example of drawing a simple circuit using schemdraw v0.6.0

This example uses schemdraw==0.6.0, but the code breaks with newer versions. TODO: update for newer schemdraw versions

import SchemDraw as sd
import SchemDraw.elements as elm

d = sd.Drawing()
V1 = d.add(elm.SOURCE_V, label='$V_g$')
d.add(elm.LINE, d='right', l=0.1*d.unit)
L1 = d.add(elm.INDUCTOR2, d='right', label='L', l=d.unit*0.75)
d.labelI_inline(L1, '$i_L$')

d.add(elm.RES, d='right', label='$R_L$', l=d.unit*0.75)
S1 = d.add(elm.SWITCH_SPDT2, d='right', anchor='a', toplabel='2', botlabel='1')

J1 = d.add(elm.LINE, d='right', xy=S1.b,  l=d.unit*.5)
J2 = d.add(elm.LINE, d='right', l=d.unit*.5)

d.add(elm.LINE, d='right', l=0.5*d.unit)
d.add(elm.GAP, d='down', toy=V1.start, label=['+', '$v$', '$-$'])

d.add(elm.LINE, d='down',toy=V1.start)
d.add(elm.LINE, to=V1.start)

d.add(elm.LINE, xy=S1.c, d='down', toy=V1.start)
C1 = d.add(elm.CAP, xy=J1.end, d='down', toy=V1.start, label='C')
d.add(elm.RES, xy=J2.end, d='down', toy=V1.start, label='R')
d.labelI_inline(C1, '$i_C$')

drawing schematics in python

Total running time of the script: ( 0 minutes 0.135 seconds)

Gallery generated by Sphinx-Gallery