# Labels¶

Labels are added to elements using the schemdraw.elements.Element.label() method. Some unicode utf-8 characters are allowed, such as '1μF' and '1MΩ' if the character is included in your font set. Alternatively, full LaTeX math expressions can be rendered when enclosed in $..$ For a description of supported math expressions, in the Matplotlib backend see Matplotlib Mathtext, and the SVG backend refer to the Ziamath package. Subscripts and superscripts are also added using LaTeX math mode, enclosed in $..$:

d += elm.Resistor().label('1MΩ')
d += elm.Capacitor().label('1μF')
d += elm.Capacitor().label(r'$v = \frac{1}{C} \int i dt$')
d += elm.Resistor().at((0, -2)).label('$R_0$')
d += elm.Capacitor().label('$x^2$')


## Location¶

The label location is specified with the loc parameter to the label method. It can be left, right, top, bottom, or the name of a defined anchor within the element. These directions do not depend on rotation. A label with loc=’left’ is always on the leftmost terminal of the element.

d += (elm.Resistor()
.label('Label')  # 'top' is default
.label('Bottom', loc='bottom')
.label('Right', loc='right')
.label('Left', loc='left'))


Labels may also be placed near an element anchor by giving the anchor name as the loc parameter.

d += (elm.BjtNpn()
.label('b', loc='base')
.label('c', loc='collector')
.label('e', loc='emitter'))


The schemdraw.elements.Element.label() method also takes parameters that control the label’s rotation, offset, font, alignment, and color. Label text stays horizontal by default, but may be rotated to the same angle as the element using rotate=True, or any angle X in degrees with rotate=X. Offsets apply vertically if a float value is given, or in both x and y if a tuple is given.

d += elm.Resistor().label('no offset')
d += elm.Resistor().label('offset', ofst=1)
d += elm.Resistor().label('offset (x, y)', ofst=(-.6, .2))
d += elm.Resistor().theta(-45).label('no rotate')
d += elm.Resistor().theta(-45).label('rotate', rotate=True)
d += elm.Resistor().theta(45).label('90°', rotate=90)


Labels may also be added anywhere using the schemdraw.elements.lines.Label element. The element itself draws nothing, but labels can be added to it:

elm.Label().label('Hello')


## Voltage Labels¶

A label may also be a list/tuple of strings, which will be evenly-spaced along the length of the element. This allows for labeling positive and negative along with a component name, for example:

d += elm.Resistor().label(('–','$V_1$','+'))  # Note: using endash U+2013 character


Use the Gap element to label voltage across a terminal:

d += elm.Line().dot(open=True)
d += elm.Gap().label(('–','$V_o$','+'))
d += elm.Line().idot(open=True)


## Current Arrow Labels¶

### Current Arrow¶

To label the current through an element, the schemdraw.elements.lines.CurrentLabel element can be added. The at method of this element can take an Element instance to label, and the arrow will be placed over the center of that Element.

d += (R1 := elm.Resistor())
d += elm.CurrentLabel().at(R1).label('10 mA')


### Inline Current Arrow¶

Alternatively, current labels can be drawn inline as arrowheads on the leads of 2-terminal elements using schemdraw.elements.lines.CurrentLabelInline. Parameters direction and start control whether the arrow is shown pointing into or out of the element, and which end to place the arrowhead on.

d += (R1 := elm.Resistor())
d += elm.CurrentLabelInline(direction='in').at(R1).label('10 mA')


### Loop Current¶

Loop currents can be added using schemdraw.elements.lines.LoopCurrent, given a list of 4 existing elements surrounding the loop.

d += (R1 := elm.Resistor())
d += (C1 := elm.Capacitor().down())
d += (D1 := elm.Diode().fill(True).left())
d += (L1 := elm.Inductor().up())
d += elm.LoopCurrent([R1, C1, D1, L1], direction='cw').label('$I_1$')


Alternatively, loop current arrows can be added anywhere with any size using schemdraw.elements.lines.LoopArrow.

d += (a:=elm.LineDot())
d += elm.LoopArrow(width=.75, height=.75).at(a.end)


### Impedance Arrow Label¶

A right-angle arrow label, often used to indicate impedance looking into a node, is added using schemdraw.elements.lines.ZLabel.

d += (R:=elm.RBox().right())
d += elm.ZLabel().at(R).label('$Z_{in}$')


## Annotations¶

To make text and arrow annotations to a schematic, the schemdraw.elements.lines.Annotate element draws a curvy arrow with label placed at it’s end. It is based on the schemdraw.elements.lines.Arc3 element.

The schemdraw.elements.lines.Encircle and schemdraw.elements.lines.EncircleBox elements draw an ellipse, or rounded rectangle, surrounding a list of elements.

d += (parallel := elm.Encircle([R1, R2], padx=.8).linestyle('--').linewidth(1).color('red'))
d += (series := elm.Encircle([R3, R4], padx=.8).linestyle('--').linewidth(1).color('blue'))

d += elm.Annotate().at(parallel.NNE).delta(dx=1, dy=1).label('Parallel').color('red')
d += elm.Annotate(th1=0).at(series.ENE).delta(dx=1.5, dy=1).label('Series').color('blue')