Plotting ngspice results with Python
Written by Lucas on
My favourite schematic capture program on Linux is Gschem, part of the gEDA project. The gEDA project contains a lot of open source tools which aid in electronic design automation. Think of programs to create schematics and PCB boards, to view Gerber files and more.
They're not as "user friendly" as OrCad or Multisim, but they work fine. For example, unlike most commercial schematic capture programs, most symbols in gEDA don't include a SPICE model by default, for most symbols you have to explicitly define which SPICE model to use when you want to start simulating. When you know what to do it's not that hard, and a project like spicelib makes it even easier.
gEDA also doesn't integrate a circuit simulator into its user interface. We do actually have some nice simulators on Linux, which are both command line based. Examples are ngspice and gnucap. Both work great, but they aren't tightly integrated as most commercial software. This can be a bit overwhelming for users who are just starting with gEDA.
Luckily, there's a nice tutorial on the gEDA wiki on how to simulate a circuit created with gEDA, and I'm not going to repeat that in this post. The point is, I don't like the builtin plot viewer of ngspice. When viewing a graph, you can't zoom, you can't move the viewport, it's just really basic. So, I've written a Python script which uses the matplotlib package to plot the results of ngspice, which looks a lot better than the builtin viewer. Details after the break!
