Module plottools.circuits
Electrical circuits.
Axes member functions
resistance_h(): draw a horizontal resistance.resistance_v(): draw a vertical resistance.resistance(): draw an arbitrarily rotated resistance.capacitance_h(): draw a horizontal capacitance.capacitance_v(): draw a vertical capacitance.battery_h(): draw a horizontal battery (voltage source).battery_v(): draw a vertical battery (voltage source).ground(): draw ground.ground_u(): draw ground upwards.opamp_l(): draw an operational amplifier with inputs on the left.opamp_l(): draw an operational amplifier with inputs on the right.chip(): draw an integrated circuit.switch_h(): draw a horizontal switch.switch_v(): draw a vertical switch.node(): draw a node connecting lines.pin(): draw a pin hole.bus(): draw a bus with label.break_h(): break a horizontal connection.break_v(): break a vertical connection.connect(): draw horizontal and vertical lines connecting circuit elements.connect_straight(): draw straight lines connecting circuit elements.
Classes
class Pos: x and y coordinate of a circuit element.
Settings
circuits_params(): set rc settings for circuits.
matplotlib.rcParams defined by the circuits module:
circuits.scale: 1
circuits.radius: 0.2
circuits.connectwidth: 1
circuits.linewidth: 2
circuits.color: 'black'
circuits.facecolor: 'white'
circuits.alpha: 1
circuits.zorder: 100
circuits.font: dict()
circuits.pinfont: dict(fontsize='small')
Install/uninstall circuits functions
You usually do not need to call these functions. Upon loading the circuits
module, install_circuits() is called automatically.
install_circuits(): install functions of the circuits module in matplotlib.uninstall_circuits(): uninstall all code of the circuits module from matplotlib.
Functions
def resistance_h(ax, pos, label='', align='above', lw=None, color=None, facecolor=None, alpha=None, zorder=None, **kwargs)-
Draw a horizontal resistance.
Parameters
ax:matplotlib axes- Axes where to draw the resistance bar.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the resistance.
label:string- Optional label for the resistance.
align:'above', 'below', 'center'- Position the label above, below or in the center of the resistance.
lw:float, int- Linewidth for drawing the outline of the resistance.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the resistance.
Defaults to
circuits.colorrcParams settings. facecolor:matplotlib color- Color for filling the resistance.
Defaults to
circuits.facecolorrcParams settings. alpha:float- Alpha value for the face color.
Defaults to
circuits.alpharcParams settings. zorder:int- zorder for the resistance and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
posl:Pos- Coordinates of the left end of the resistance.
posr:Pos- Coordinates of the right end of the resistance.
Raises
Valueerror
Invalid value for
align. def resistance_v(ax, pos, label='', align='right', lw=None, color=None, facecolor=None, alpha=None, zorder=None, **kwargs)-
Draw a vertical resistance.
Parameters
ax:matplotlib axes- Axes where to draw the resistance.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the resistance.
label:string- Optional label for the resistance.
align:'left', 'right', 'center'- Position the label to the left, right or in the center of the resistance.
lw:float, int- Linewidth for drawing the outline of the resistance.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the resistance.
Defaults to
circuits.colorrcParams settings. facecolor:matplotlib color- Color for filling the resistance.
Defaults to
circuits.facecolorrcParams settings. alpha:float- Alpha value for the face color.
Defaults to
circuits.alpharcParams settings. zorder:int- zorder for the resistance and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
posb:Pos- Coordinates of the bottom end of the resistance.
post:Pos- Coordinates of the top end of the resistance.
Raises
Valueerror
Invalid value for
align. def resistance(ax, pos, angle=0, label='', align='above', lw=None, color=None, facecolor=None, alpha=None, zorder=None, **kwargs)-
Draw an arbitrarily rotated resistance.
Parameters
ax:matplotlib axes- Axes where to draw the resistance bar.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the resistance.
angle:float- Rotation angle in degrees.
label:string- Optional label for the resistance.
align:'above', 'below', 'center'- Position the label above, below or in the center of the non-rotated resistance.
lw:float, int- Linewidth for drawing the outline of the resistance.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the resistance.
Defaults to
circuits.colorrcParams settings. facecolor:matplotlib color- Color for filling the resistance.
Defaults to
circuits.facecolorrcParams settings. alpha:float- Alpha value for the face color.
Defaults to
circuits.alpharcParams settings. zorder:int- zorder for the resistance and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
posl:Pos- Coordinates of the left end of the resistance.
posr:Pos- Coordinates of the right end of the resistance.
Raises
Valueerror
Invalid value for
align. def capacitance_h(ax, pos, label='', align='above', lw=None, color=None, zorder=None, **kwargs)-
Draw a horizontal capacitance.
Parameters
ax:matplotlib axes- Axes where to draw the capacitance.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the capacitance.
label:string- Optional label for the capacitance.
align:'above', 'below'- Position the label above or below the capacitance.
lw:float, int- Linewidth for drawing the outline of the capacitance.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the capacitance.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the capacitance and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
posl:Pos- Coordinates of the left end of the capacitance.
posr:Pos- Coordinates of the right end of the capacitance.
Raises
Valueerror
Invalid value for
align. def capacitance_v(ax, pos, label='', align='right', lw=None, color=None, zorder=None, **kwargs)-
Draw a vertical capacitance.
Parameters
ax:matplotlib axes- Axes where to draw the capacitance.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the capacitance.
label:string- Optional label for the capacitance.
align:'left', 'right'- Position the label to the left or to the right of the capacitance.
lw:float, int- Linewidth for drawing the outline of the capacitance.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the capacitance.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the capacitance and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
posb:Pos- Coordinates of the bottom end of the capacitance.
post:Pos- Coordinates of the top end of the capacitance.
Raises
Valueerror
Invalid value for
align. def battery_h(ax, pos, label='', align='above', lw=None, color=None, zorder=None, **kwargs)-
Draw a horizontal battery (voltage source).
Parameters
ax:matplotlib axes- Axes where to draw the battery.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the battery.
label:string- Optional label for the battery.
align:'above', 'below'- Position the label above or below the battery.
lw:float, int- Linewidth for drawing the outline of the battery.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the battery.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the battery and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
posl:Pos- Coordinates of the left end of the battery.
posr:Pos- Coordinates of the right end of the battery.
Raises
Valueerror
Invalid value for
align. def battery_v(ax, pos, label='', align='right', lw=None, color=None, zorder=None, **kwargs)-
Draw a vertical battery (voltage source).
Parameters
ax:matplotlib axes- Axes where to draw the battery.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the battery.
label:string- Optional label for the battery.
align:'left', 'right'- Position the label to the left or to the right of the battery.
lw:float, int- Linewidth for drawing the outline of the battery.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the battery.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the battery and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
posb:Pos- Coordinates of the bottom end of the battery.
post:Pos- Coordinates of the top end of the battery.
Raises
Valueerror
Invalid value for
align. def ground(ax, pos, label='', align='right', lw=None, color=None, zorder=None, **kwargs)-
Draw ground.
Parameters
ax:matplotlib axes- Axes where to draw the battery.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of ground.
label:string- Optional label for the battery.
align:'left', 'right'- Position the label to the left or to the right of the ground.
lw:float, int- Linewidth for drawing the outline of the battery.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the battery.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the battery and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
pos:Pos- Coordinates of the top end of ground.
Raises
Valueerror
Invalid value for
align. def ground_u(ax, pos, label='', align='right', lw=None, color=None, zorder=None, **kwargs)-
Draw ground upwards.
Parameters
ax:matplotlib axes- Axes where to draw the battery.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of ground.
label:string- Optional label for the battery.
align:'left', 'right'- Position the label to the left or to the right of the ground.
lw:float, int- Linewidth for drawing the outline of the battery.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the battery.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the battery and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
pos:Pos- Coordinates of the bottom end of ground.
Raises
Valueerror
Invalid value for
align. def opamp_l(ax, pos, label='', align='above', invert=False, lw=None, color=None, facecolor=None, alpha=None, zorder=None, **kwargs)-
Draw an operational amplifier with inputs on the left.
Parameters
ax:matplotlib axes- Axes where to draw the opamp.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the opamp.
label:string- Optional label for the opamp.
align:'above', 'below', 'center'- Position the label above, below or in the center of the opamp.
invert:bool- If True invert the inputs, i.e. have the inverting input at the top.
lw:float, int- Linewidth for drawing the outline of the opamp.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the opamp.
Defaults to
circuits.colorrcParams settings. facecolor:matplotlib color- Color for filling the opamp.
Defaults to
circuits.facecolorrcParams settings. alpha:float- Alpha value for the face color.
Defaults to
circuits.alpharcParams settings. zorder:int- zorder for the opamp and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
pospos:Pos- Coordinates of the positive (upper) input of the opamp.
posneg:Pos- Coordinates of the negative (lower) input of the opamp.
posout:Pos- Coordinates of the output of the opamp.
posgnd:Pos- Coordinates of the ground supply of the opamp.
pospwr:Pos- Coordinates of the power supply of the opamp.
Raises
Valueerror
Invalid value for
align. def opamp_r(ax, pos, label='', align='above', invert=False, lw=None, color=None, facecolor=None, alpha=None, zorder=None, **kwargs)-
Draw an operational amplifier with inputs on the right.
Parameters
ax:matplotlib axes- Axes where to draw the opamp.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the opamp.
label:string- Optional label for the opamp.
align:'above', 'below', 'center'- Position the label above, below or in the center of the opamp.
invert:bool- If True invert the inputs, i.e. have the inverting input at the top.
lw:float, int- Linewidth for drawing the outline of the opamp.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the opamp.
Defaults to
circuits.colorrcParams settings. facecolor:matplotlib color- Color for filling the opamp.
Defaults to
circuits.facecolorrcParams settings. alpha:float- Alpha value for the face color.
Defaults to
circuits.alpharcParams settings. zorder:int- zorder for the opamp and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
pospos:Pos- Coordinates of the positive (upper) input of the opamp.
posneg:Pos- Coordinates of the negative (lower) input of the opamp.
posout:Pos- Coordinates of the output of the opamp.
posgnd:Pos- Coordinates of the ground supply of the opamp.
pospwr:Pos- Coordinates of the power supply of the opamp.
Raises
Valueerror
Invalid value for
align. def chip(ax, pos, pins_left=3, pins_right=3, pins_top=2, pins_bottom=2, palign='top left', label='', align='above', rotation='horizontal', radius=None, lw=None, color=None, facecolor=None, alpha=None, zorder=None, pinfont=None, **kwargs)-
Draw an integrated circuit.
Just a rectangular block with pins on the left, right, top, and bottom. The size of the chip is deduced from the pins it needs to accomodate.
Parameters
ax:matplotlib axes- Axes where to draw the chip.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the chip.
pins_left:intorlistofstrorNone- If integer, the number of pins on the left side of the chip. If list, then the list elements are the labels for the pins on the left side of the chip. Labels can be empty. If a label is None then this pin will be omitted.
pins_right:intorlistofstrorNone- If integer, the number of pins on the right side of the chip. If list, then the list elements are the labels for the pins on the right side of the chip. Labels can be empty. If a label is None then this pin will be omitted.
pins_top:intorlistofstrorNone- If integer, the number of pins on the top side of the chip. If list, then the list elements are the labels for the pins on the top side of the chip. Labels can be empty. If a label is None then this pin will be omitted.
pins_bottom:intorlistofstrorNone- If integer, the number of pins on the bottom side of the chip. If list, then the list elements are the labels for the pins on the bottom side of the chip. Labels can be empty. If a label is None then this pin will be omitted.
palign:string- Where to label the strings: "inside" or a combination of "left", "right", "top", "bottom".
label:string- Optional label for the chip.
align:'left', 'right', 'top', 'bottom', 'above', 'below', 'center'- Position the label above, below or in the center of the chip.
rotation:strorfloat- Rotation angle of the label in degrees or 'horizontal' or 'vertical'.
radius:float- Radius of the rounded corners of the chip as a fraction of
circuits.scale. Defaults tocircuits.radiusrcParams settings. lw:float, int- Linewidth for drawing the outline of the opamp.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the opamp.
Defaults to
circuits.colorrcParams settings. facecolor:matplotlib color- Color for filling the opamp.
Defaults to
circuits.facecolorrcParams settings. alpha:float- Alpha value for the face color.
Defaults to
circuits.alpharcParams settings. zorder:int- zorder for the opamp and the label.
Defaults to
circuits.zorderrcParams settings. pinfont:dict- Dictionary with font settings used for labeling pins.
Defaults to
circuits.pinfontrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
pos_left:listofPos- Coordinates of the left pins (whose label is not None).
pos_righ:listofPos- Coordinates of the right pins (whose label is not None).
pos_top:listofPos- Coordinates of the top pins (whose label is not None).
pos_bottom:listofPos- Coordinates of the bottom pins (whose label is not None).
Raises
Valueerror
Invalid value for
align. def switch_h(ax, pos, label='', align='above', lw=None, color=None, zorder=None, **kwargs)-
Draw a horizontal switch.
Parameters
ax:matplotlib axes- Axes where to draw the switch.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the switch.
label:string- Optional label for the switch.
align:'above', 'below'- Position the label above or below the switch.
lw:float, int- Linewidth for drawing the wire of the switch.
Defaults to
circuits.connectwidthrcParams settings. color:matplotlib color- Color for the wire of the switch.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the switch and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
posl:Pos- Coordinates of the left end of the switch.
posr:Pos- Coordinates of the right end of the switch.
Raises
Valueerror
Invalid value for
align. def switch_v(ax, pos, label='', align='right', lw=None, color=None, zorder=None, **kwargs)-
Draw a vertical switch.
Parameters
ax:matplotlib axes- Axes where to draw the switch.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the switch.
label:string- Optional label for the switch.
align:'left', 'right'- Position the label to the left or right of the switch.
lw:float, int- Linewidth for drawing the wire of the switch.
Defaults to
circuits.connectwidthrcParams settings. color:matplotlib color- Color for the wire of the switch.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the switch and the label.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
posb:Pos- Coordinates of the bottom end of the switch.
post:Pos- Coordinates of the top end of the switch.
Raises
Valueerror
Invalid value for
align. def node(ax, pos, label='', align='northeast', color=None, zorder=None, **kwargs)-
Draw a node connecting lines.
Parameters
ax:matplotlib axes- Axes where to draw the node.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the node.
label:string- Optional label for the node.
align:'left', 'right', 'above', 'below', 'north', 'south', 'west', 'east', 'northwest', 'northeast', 'southwest', 'southeast'- Position of the label relative to the node.
color:matplotlib color- Color of the node.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the node.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
pos:Pos- Coordinates of the node.
Raises
Valueerror
Invalid value for
align. def pin(ax, pos, label='', align='northeast', lw=None, color=None, facecolor=None, alpha=None, zorder=None, **kwargs)-
Draw a pin hole.
Parameters
ax:matplotlib axes- Axes where to draw the pin hole.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the pin hole.
label:string- Optional label for the pin hole.
align:'left', 'right', 'above', 'below', 'north', 'south', 'west', 'east', 'northwest', 'northeast', 'southwest', 'southeast'- Position of the label relative to the pin hole.
lw:float, int- Linewidth for drawing the outline of the pin hole.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the pin hole.
Defaults to
circuits.colorrcParams settings. facecolor:matplotlib color- Color for filling the pin hole.
Defaults to
circuits.facecolorrcParams settings. alpha:float- Alpha value for the face color.
Defaults to
circuits.alpharcParams settings. zorder:int- zorder for the node.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
pos:Pos- Coordinates of the pin hole.
Raises
Valueerror
Invalid value for
align. def bus(ax, pos, label='', align='left', lw=None, color=None, facecolor=None, alpha=None, zorder=None, **kwargs)-
Draw a bus with label.
Parameters
ax:matplotlib axes- Axes where to draw the bus.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the tip of bus label.
label:string- Optional label for the bus.
align:'left', 'right', 'top', 'bottom', 'above', 'below', 'north', 'south', 'west', 'east'- Position of the bus relative to the pos.
lw:float, int- Linewidth for drawing the outline of the bus label.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color for the outline of the bus label.
Defaults to
circuits.colorrcParams settings. facecolor:matplotlib color- Color for filling the bus label.
Defaults to
circuits.facecolorrcParams settings. alpha:float- Alpha value for the face color.
Defaults to
circuits.alpharcParams settings. zorder:int- zorder for the bus.
Defaults to
circuits.zorderrcParams settings. kwargs:key-word arguments- Passed on to
ax.text()used to print the label. Defaults tocircuits.fontrcParams settings.
Returns
pos:Pos- Coordinates of the tip of the bus.
Raises
Valueerror
Invalid value for
align. def break_h(ax, pos, lw=None, color=None, zorder=None)-
Break a horizontal connection.
Parameters
ax:matplotlib axes- Axes where to draw the break.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the break.
lw:float, int- Linewidth for drawing the connection lines.
Defaults to
circuits.connectwidthrcParams settings. color:matplotlib color- Color of the connection lines.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the connection lines.
Defaults to
circuits.zorderrcParams settings.
Returns
def break_v(ax, pos, lw=None, color=None, zorder=None)-
Break a vertical connection.
Parameters
ax:matplotlib axes- Axes where to draw the break.
pos:Posor2-tupleoffloats- x and y-coordinate of position of the center of the break.
lw:float, int- Linewidth for drawing the connection lines.
Defaults to
circuits.connectwidthrcParams settings. color:matplotlib color- Color of the connection lines.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the connection lines.
Defaults to
circuits.zorderrcParams settings.
Returns
def connect(ax, nodes, lw=None, color=None, zorder=None)-
Draw horizontal and vertical lines connecting circuit elements.
Parameters
ax:matplotlib axes- Axes where to draw the connections.
nodes:listofPosor2-tupleoffloats- x and y-coordinates of positions that should be connected.
If an element is
Nonethen leave a gap between the neighboring nodes. Makes only horizontal and vertical connection lines in counter-clockwise direction. lw:float, int- Linewidth for drawing the connection lines.
Defaults to
circuits.connectwidthrcParams settings. color:matplotlib color- Color of the connection lines.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the connection lines.
Defaults to
circuits.zorderrcParams settings.
def connect_straight(ax, nodes, lw=None, color=None, zorder=None)-
Draw straight lines connecting circuit elements.
Parameters
ax:matplotlib axes- Axes where to draw the connections.
nodes:listofPosor2-tupleoffloats- x and y-coordinates of positions that should be connected.
If an element is
Nonethen leave a gap between the neighboring nodes. lw:float, int- Linewidth for drawing the connection lines.
Defaults to
circuits.linewidthrcParams settings. color:matplotlib color- Color of the connection lines.
Defaults to
circuits.colorrcParams settings. zorder:int- zorder for the connection lines.
Defaults to
circuits.zorderrcParams settings.
def circuits_params(scale=None, radius=None, connectwidth=None, linewidth=None, color=None, facecolor=None, alpha=None, zorder=None, font=None, pinfont=None)-
Set rc settings for circuits.
Only parameters that are not
Noneare updated.Parameters
scale:float- Size of circuit elements as the height of a vertical resistance in x/y coordinate units.
radius:float- Radius of rounded corners (e.g. of a chip) as a fraction of
circuits.scale. connectwidth:int, float- Line width of lines connecting circuit elements.
Set rcParam
circuits.connectwidth. linewidth:int, float- Line width used for drawing circuit elements.
Set rcParam
circuits.linewidth. color:matplotlib color- Color of the connections and circuit elements.
Set rcParam
circuits.color. facecolor:matplotlib color- Face color for closed circuit elements like resistances or opamps.
Set rcParam
circuits.facecolor. alpha:float- Alpha value for face color for closed circuit elements like
resistances or opamps.
Set rcParam
circuits.alpha. zorder:int- Zorder for all circuit elements drawn.
Set rcParam
circuits.zorder. font:dict- Dictionary with font settings used for labeling circuit elements
(e.g. fontsize, fontfamiliy, fontstyle, fontweight, bbox, …).
Set rcParam
circuits.font. pinfont:dict- Dictionary with font settings used for labeling pins, e.g. of a chip.
Set rcParam
circuits.pinfont.
def install_circuits()-
Install circuits functions on matplotlib axes.
This function is also called automatically upon importing the module.
See Also
def uninstall_circuits()-
Uninstall circuits functions from matplotlib axes.
Call this code to disable anything that was installed by
install_circuits().See Also
def demo()
Classes
class Pos (x, y)-
x and y coordinate of a circuit element.
Expand source code
class Pos(tuple): """ x and y coordinate of a circuit element. """ def __new__(cls, x, y): return tuple.__new__(cls, (x, y)) def x(self): """ x coordinate of the circuit element. Returns ------- x: float x-coordinate """ return self[0] def y(self): """ y coordinate of the circuit element. Returns ------- y: float y-coordinate """ return self[1] def up(self, delta=1): """ Increment y coordinate of position of circuit element. Parameters ---------- delta: float Increment in data coordinates. Returns ------- pos: Pos Incremented copy of position of circuit element. """ return Pos(self[0], self[1] + delta) def down(self, delta=1): """ Decrement y coordinate of position of circuit element. Parameters ---------- delta: float Decrement in data coordinates. Returns ------- pos: Pos Decremented copy of position of circuit element. """ return Pos(self[0], self[1] - delta) def left(self, delta=1): """ Decrement x coordinate of position of circuit element. Parameters ---------- delta: float Decrement in data coordinates. Returns ------- pos: Pos Decremented copy of position of circuit element. """ return Pos(self[0] - delta, self[1]) def right(self, delta=1): """ Increment x coordinate of position of circuit element. Parameters ---------- delta: float Increment in data coordinates. Returns ------- pos: Pos Incremented copy of position of circuit element. """ return Pos(self[0] + delta, self[1]) def ups(self, delta=1): """ Increment y coordinate of position of circuit element. Parameters ---------- delta: float Increment in multiples of circuits scale (rcParam `circuits.scale`). Returns ------- pos: Pos Incremented copy of position of circuit element. """ return Pos(self[0], self[1] + delta*mpl.rcParams['circuits.scale']) def downs(self, delta=1): """ Decrement y coordinate of position of circuit element. Parameters ---------- delta: float Decrement in multiples of circuits scale (rcParam `circuits.scale`). Returns ------- pos: Pos Decremented copy of position of circuit element. """ return Pos(self[0], self[1] - delta*mpl.rcParams['circuits.scale']) def lefts(self, delta=1): """ Decrement x coordinate of position of circuit element. Parameters ---------- delta: float Decrement in multiples of circuits scale (rcParam `circuits.scale`). Returns ------- pos: Pos Decremented copy of position of circuit element. """ return Pos(self[0] - delta*mpl.rcParams['circuits.scale'], self[1]) def rights(self, delta=1): """ Increment x coordinate of position of circuit element. Parameters ---------- delta: float Increment in multiples of circuits scale (rcParam `circuits.scale`). Returns ------- pos: Pos Incremented copy of position of circuit element. """ return Pos(self[0] + delta*mpl.rcParams['circuits.scale'], self[1])Ancestors
- builtins.tuple
Methods
def x(self)-
x coordinate of the circuit element.
Returns
x:float- x-coordinate
def y(self)-
y coordinate of the circuit element.
Returns
y:float- y-coordinate
def up(self, delta=1)-
Increment y coordinate of position of circuit element.
Parameters
delta:float- Increment in data coordinates.
Returns
pos:Pos- Incremented copy of position of circuit element.
def down(self, delta=1)-
Decrement y coordinate of position of circuit element.
Parameters
delta:float- Decrement in data coordinates.
Returns
pos:Pos- Decremented copy of position of circuit element.
def left(self, delta=1)-
Decrement x coordinate of position of circuit element.
Parameters
delta:float- Decrement in data coordinates.
Returns
pos:Pos- Decremented copy of position of circuit element.
def right(self, delta=1)-
Increment x coordinate of position of circuit element.
Parameters
delta:float- Increment in data coordinates.
Returns
pos:Pos- Incremented copy of position of circuit element.
def ups(self, delta=1)-
Increment y coordinate of position of circuit element.
Parameters
delta:float- Increment in multiples of circuits scale (rcParam
circuits.scale).
Returns
pos:Pos- Incremented copy of position of circuit element.
def downs(self, delta=1)-
Decrement y coordinate of position of circuit element.
Parameters
delta:float- Decrement in multiples of circuits scale (rcParam
circuits.scale).
Returns
pos:Pos- Decremented copy of position of circuit element.
def lefts(self, delta=1)-
Decrement x coordinate of position of circuit element.
Parameters
delta:float- Decrement in multiples of circuits scale (rcParam
circuits.scale).
Returns
pos:Pos- Decremented copy of position of circuit element.
def rights(self, delta=1)-
Increment x coordinate of position of circuit element.
Parameters
delta:float- Increment in multiples of circuits scale (rcParam
circuits.scale).
Returns
pos:Pos- Incremented copy of position of circuit element.