ngspice Matplotlib Plot
Use this skill when a task needs to run ngspice on a .cir file and turn the generated wrdata output into a plot.
Environment Requirements
- A Python environment with
matplotlibinstalled. ngspiceinstalled and callable asngspice.- The bundled script writes matplotlib config and cache data into the current working directory if needed.
- Prefer a project-local
.venvwhen one exists. - If no project-local environment exists, use a Python interpreter explicitly instead of assuming
pythonresolves correctly. - Before invoking Python plotting, it is safe to set:
MPLCONFIGDIR="$(pwd)/.mplconfig" XDG_CACHE_HOME="$(pwd)/.cache"
Default Workflow
- Confirm the
.cirfile contains awrdata ...line. - Choose a Python interpreter:
- Prefer
./.venv/bin/pythonif the repo already has one. - Otherwise use an explicitly chosen interpreter such as
python3.
- Prefer
- Run the bundled script with that interpreter.
- By default, let the script delete the generated
.datfile after plotting. - Use
--keep-dataonly when the user wants to inspect or reuse the raw exported data.
Command Pattern
MPLCONFIGDIR="$(pwd)/.mplconfig" \
XDG_CACHE_HOME="$(pwd)/.cache" \
python3 \
~/.codex/skills/ngspice-matplotlib-plot/scripts/run_ngspice_and_plot.py \
<path-to-netlist.cir> [--output output.png] [--title "Plot Title"] [--keep-data]
Notes
- The script expects
wrdataoutput in the netlist. It parses the file name and expressions from that command. - The generated image defaults to
<netlist_stem>_plot.pngin the same directory as the netlist. - The bundled script uses the non-interactive
Aggmatplotlib backend, so it works in headless terminal sessions. - If a collaborator stores skills somewhere other than
~/.codex/skills/, adjust the script path accordingly.