I've recently finished some work with hspice, and now I don't have access to the server. I've installed ngspice on my Fedora 15 machine, but I'm unfamiliar with how it works. In hspice, I was able to produce an output file with measured values and a set of waveforms that were plotted out with cosmosscope easily.

However, I'm unsure of how to do this in ngspice. Here's some basic SPICE code:

Transient Response of a Linear Network

** Circuit Description **

* input signal source
Vi 1 0 SIN ( 0V 10V 60Hz )
* linear network
R1      1   2   1Ohm
C1      2   0   2.65mF
Rload   3   0   10Ohm
E1      3   0   2   0   10

** Analysis Request **
* compute transient response of circuit over three full
* periods (50 ms) of the 60 Hz sine-wave input with a 1 ms
* sampling interval
.TRAN 1ms 50ms 0ms 1ms

** Output Request **
* print the output and input time-varying waveforms
* plot the output and input time-varying waveforms
* set the range of the y-axis between -100 and +100 V
.PLOT TRAN V(3) V(1) (-100,+100)


How to I get ngspice to output the values requested as well as plot the values requested AT ONCE?

UPDATE: I've gotten more familiar with ngspice. It seems it was indeed able to output the data I wanted and it can plot data. However, I have to do this separately with different commands in the ngspice interpreter. I'm wondering how can I get ngspice to simply plot everything and output all the data in a single go. Here's a picture of how it works:

  • \$\begingroup\$ Did you try out the iplot (incremental plot) command? The asciiplot command is also interesting :-) \$\endgroup\$ Apr 30, 2016 at 20:21

1 Answer 1


You can put interpreter command between .control and .endc commands in the circuit file. This way they should run together with the simulation.

PS. For more involved plotting and post-processing you can start with tabular data from SPICE and feed it to gnuplot or Python+numpy+matplotlib.

PS. Keep in mind that ngspice is based on Berkeley Spice 3 (rewritten in C) while most commercial SPICE engines were based on the 2nd version (in Fortran). Differences are mostly with ngspice supporting textual node names and arbitrary mathematical functions in dependent current/voltage sources. This last thing frequently causes headaches when trying to use manufacturer provided IC models which use the old (and unsupported in ngspice) POLY declaration.

  • \$\begingroup\$ It does plot out data, I've updated the question a bit. \$\endgroup\$
    – sj755
    Aug 18, 2011 at 3:58
  • \$\begingroup\$ NGSPICE supports POLY statements through its XSPICE codemodels. XSPICE support is default on. \$\endgroup\$ Jan 15, 2018 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.