Create plots
SLiCAP provides some plot functions that facilitate easy plotting of graphs from execution results with automatic determination of colors, markers, plot legends, and axis labels.
Plot functions are collected in the SLiCAP module SLiCAPplots.py.
SLiCAP plots are hierarchically structured:
A figure object is the main object that can be plotted using its
.plot()
method.The figure’s
.axis
attribute is a list of lists with axis objects for one row, from left to right.The
.traces
attribute of each axis object is a list with trace objects that will be plotted the axis. Trace xdata, ydata, lables, colors, markers, etc, are all attributes of a trace object.
SLiCAP built-in figures are single-axis figures.
-
The function plotSweep() displays traces from expressions with one symbolic variable. It can be used for plotting time-domain responses, frequency-domain responses, and arbitrary single-variable functions.
Pole-zero and root-locus plots
The function plotPZ() displays X-Y scatter plots. These plots are configured for plotting the results of pole-zero analysis.
-
The function plot() generates X-Y line plots from a dictionary with traces. Such dictionaries can be generated from data from other applications, such as, LTspice, SImetrix, NGspice, or Cadence, or from
.csv
files (see Plot data from other applications).
Plots with a swept x-variable
Below a few examples using plotSweep().
import SLiCAP as sl
sl.initProject('My first RC network') # Initialize a SLiCAP project
cir = sl.makeCircuit('kicad/myFirstRCnetwork/myFirstRCnetwork.kicad_sch')
numGain = sl.doLaplace(cir, pardefs="circuit, numeric=True)
figMag = plotSweep('RCmag', 'Magnitude characteristic', numGain, 10, '100k', 100, yUnits = '-', show = True)
figPol = plotSweep('RCpolar', 'Polar plot', numGain, 10, '100k', 100, axisType = 'polar', show = True)
figdBmag = plotSweep('RCdBmag', 'dB magnitude characteristic', numGain, 10, '100k', 100, funcType = 'dBmag', show = True)
figPhase = plotSweep('RCphase', 'Phase characteristic', numGain, 10, '100k', 100, funcType = 'phase', show = True)
figDelay = plotSweep('RCdelay', 'Group delay characteristic', numGain, 10, '100k', 100, yScale = 'u', funcType = 'delay', show = True)
numStep = doStep(cir, pardefs="circuit", numeric=True)
figStep = plotSweep('RCstep', 'Unit step response', numStep, 0, 1, 50, sweepScale='m', show = True)
Stepping parameters
If a stepped-parameter instruction is executed, multiple traces will be plotted on the axis, one for each step value. The legend will show the step variable and its value.
For array type stepping the legend text will be run: <i>
where the number i
indicates the i-th step using the i-th value for each step parameter.
Sweeping parameters
Cicuit parameters can be assigned a numeric value or a function of other parameters. In the case of a single-variable function it can be plotted with the plotSweep() function.
Pole-zero and root-locus plots
import SLiCAP as sl
sl.initProject('My first RC network')
cir = sl.makeCircuit('kicad/myFirstRCnetwork/myFirstRCnetwork.kicad_sch')
pzGain = doPZ(cir, pardefs="circuit", numeric=True)
figPZ = plotPZ('PZ', 'Poles and zeros of the RC network', pzGain)
Stepping parameters and root locus plots
SLiCAP can plot the poles and zeros while stepping parameters. A root-locus plot in SLiCAP is essensially a parametric doPZ() instruction. The formatting of the stepped pole-zero plots is as follows:
doPoles() or doPZ():
marker for each pole, first step: \(\times\)
marker for each pole, last step: \(+\)
marker for each pole, each step: \(\bullet\)
doZeros() or doPZ():
marker for each zero, first step: \(\circ\)
marker for each zero, last step: \(\Box\)
marker for each zero, each step: \(\bullet\)
Paths of poles and/or zeros traced out by stepping parameters are displayed as a collection of dots: \(\bullet\). Only the first value and the last value of the step parameter is displayed in the legend. For array type stepping only run: 1 and run: <number of steps> is displayed in the legend.
X-Y plots
Plot data from other applications
Add traces to a figure
The function traces2fig() adds traces to a figure.