LTspice integration
Export simulation results
- Run your simulation in LTspice.
- Activate the waveform viewer. Choose File → Export data as text.
- Select the traces and save the file alongside your Python script.
import plotora as pt
sim = pt.read_ltspice("examples/capacitor_4700.txt")
print(sim.traces, sim.step_names)
pt.ltspice(sim, traces=["V(out)"], time_unit="ms").save("output.pdf").show()
The included capacitor data are synthetic examples. Replace the filename with your own exported results. Trace names must match the file headers exactly. Text input supports tab-delimited exports, CSV with quoted complex cells, UTF-8, BOM-marked UTF-16 and CP1252, and Step Information: separators.
Compare and measure
pt.compare_ltspice(
"examples/capacitor_4700.txt", "examples/capacitor_6800.txt",
trace="V(out)", labels=["4700 µF", "6800 µF"], time_unit="ms"
).show()
print(sim.metrics("V(out)", window=(0.06, 0.10)))

compare_ltspice accepts single-run transient files. ltspice accepts a path or a Simulation; step=None plots all runs, step=0 selects the first, or pass a list of indices. window uses original axis units even when time is displayed in milliseconds. The plot selects samples within the window; metrics interpolate the boundaries and require the window to lie inside the data range.
The metrics dictionary contains minimum, maximum, peak_to_peak, average, rms and ripple_rms. Average is time-weighted by trapezoidal integration and RMS uses piecewise-linear interpolation. Sampled extrema may miss true peaks. Separate current and voltage figures to avoid mixed units.
AC and RAW data
For AC exports, component="db" selects magnitude in dB; phase selects unwrapped degrees. Other choices: magnitude, real, imag. The frequency axis uses Hz and a logarithmic scale by default. dB refers to the exported trace, not automatically to a transfer function.
Native RAW import uses spicelib: install the engineering extra, then call pt.ltspice("circuit.raw"). Keep the associated simulator log for stepped simulations. This integration is implemented but has not been verified with real RAW files in RC1; prefer text export for critical work.