LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Can someone help me with ngspice syntax to use gnuplot for output? Output blank! (https://www.linuxquestions.org/questions/linux-software-2/can-someone-help-me-with-ngspice-syntax-to-use-gnuplot-for-output-output-blank-4175434983/)

keithostertag 10-31-2012 07:33 PM

Can someone help me with ngspice syntax to use gnuplot for output? Output blank!
 
I'm hoping someone here is familiar with ngspice who can guide me through this. I have been trying for days for a way to export ngspice plots/graphs to some kind of image file, like png, so I can post it to a web page or send via email.

I can use the hardcopy command to create an eps file, but it is not anywhere near as nice looking as the plot displayed with the plot command.

Someone had suggested I try gnuplot, but I haven't been able to get that to work for me. The ngspice manual section on using gnuplot for output is very terse, just a few sentences at 17.5.25, page 285.

test2.net is the name of the netlist I am currently working on. Here it is:
Code:

ngspice 2 -> listing
        bipolar transistor simulation

    1 : bipolar transistor simulation
    2 : .global gnd
    3 : i1 0 1 dc 75u
    4 : q1 2 1 0 mod1
    5 : vammeter 3 2 dc 0
    6 : v1 3 0 dc
    7 : .model mod1 npn
    9 : .end


When at the ngspice command prompt I do:
Code:

ngspice 2 -> gnuplot test2 v(1)
I am presented with a new window with a gnuplot prompt. I was expecting a plot window!?!

As the manual says, ngspice creates three files, test2.data, test2.plt, and test2.eps. If I open the eps file (using a different terminal) it is blank, whether I open it with gv, gimp or anything else. The eps file is not empty, it just shows nothing.

I am unfamiliar with gnuplot, and don't want to have to learn all it's syntax just to get an image. I tried:
Code:

gnuplot> load 'test2.plt'
and that appears to write to test2.eps again (by looking at the timestamp), but again the test2.eps file when opened in gv is blank.

I am wondering if there is a problem with the way I'm asking gnuplot to write the output. Or could there be some kind of configuration parameter I need to set?

I'm using Debian with i3 tiling wm. In case it is helpful here is a link to the test2.eps file: www.strucktower.com/test2.eps

Any ideas?

Thanks,
Keith

Here is test2.plt:
Code:

keith@t520:~/gaf$ cat test2.plt
set title "bipolar transistor simulation "
set xlabel "V"
set ylabel "V"
set grid
unset logscale x
set xrange [0.000000e+00:5.000000e+01]
unset logscale y
set yrange [6.653309e-01:8.264312e-01]
#set xtics 1
#set x2tics 1
#set ytics 1
#set y2tics 1
plot 'test2.data' using 1:2 with lines lw 1 title "v(1)"
set terminal push
set terminal postscript eps color
set out 'test2.eps'
replot
set term pop
replot


sljunkie 03-26-2014 05:19 PM

Hi,

The command 'hardcopy' can help.

For example add these lines to /usr/share/ngspice/scripts/spinit :

Code:

** set hardcopy format
set hcopydevtype=postscript
set hcopypscolor=1

Do the analysis and then at the ngspice prompt:

Code:

hardcopy test.ps v(1)
You will have a colored .ps file ready to be printed/exported ;)

jlinkels 03-26-2014 05:56 PM

The .plt file looks reasonably decent. I am just not fond of .eps. It integrates nicely with Latex, but that is the only use I found for it.

First of all, check if your test2.dta contains sensible data. It should contain 2 columns. Column 1 the X-axis values, column 2 the Y-axis values.

If the test2.dta is correct, modify the last lines of the test2.plt to this:

Code:

set title "bipolar transistor simulation "
set xlabel "V"
set ylabel "V"
set grid
unset logscale x
set xrange [0.000000e+00:5.000000e+01]
unset logscale y
set yrange [6.653309e-01:8.264312e-01]
#set xtics 1
#set x2tics 1
#set ytics 1
#set y2tics 1
set term png size 800,600
set output "test2.png"

plot 'test2.data' using 1:2 with lines lw 1 title "v(1)"

Then do on the command line:
gnuplot < test2.plt (make sure the data file is in the current directory)

This should produce output. If you see error messages, post them.

Next, in the ngspice file control section you can specify gnuplot_terminal png. After running ngspice check the test2.plt file again and see that set term eps is replaced by set term png. Run the .plt file again with gnuplot < test2.plt and see what happens.

It is a nuisance that gnuplot is opened, the plot is created on screen and then once more put into a file. Unless you want to alter each .plt file you have to live with that.

jlinkels


All times are GMT -5. The time now is 05:59 PM.