Browse Source

When plotting arrays of curves, plot lines only in the direction

of (in absolute terms) growing x values.
Example: MOS output characteristics.
In the rare case of plotting versus varying x directions
(e.g. example memristor.sp), one has to add the flag
'retraceplot' to the plot command.
pre-master-46
Holger Vogt 6 years ago
parent
commit
e53632c368
  1. 4
      examples/memristor/memristor.sp
  2. 8
      examples/memristor/memristor_x.sp
  3. 2
      src/frontend/plotting/gnuplot.c
  4. 2
      src/frontend/plotting/plotcurv.c
  5. 10
      src/frontend/plotting/plotit.c
  6. 2
      src/include/ngspice/dvec.h

4
examples/memristor/memristor.sp

@ -57,9 +57,9 @@ plot tran1.alli tran2.alli alli title 'Memristor with threshold: Internal Progra
settype impedance xmem.x1 tran1.xmem.x1 tran2.xmem.x1 settype impedance xmem.x1 tran1.xmem.x1 tran2.xmem.x1
plot xmem.x1 tran1.xmem.x1 tran2.xmem.x1 title 'Memristor with threshold: resistance' plot xmem.x1 tran1.xmem.x1 tran2.xmem.x1 title 'Memristor with threshold: resistance'
* resistance versus voltage (change occurs only above threshold!) * resistance versus voltage (change occurs only above threshold!)
plot xmem.x1 vs v(1) tran1.xmem.x1 vs tran1.v(1) tran2.xmem.x1 vs tran2.v(1) title 'Memristor with threshold: resistance'
plot xmem.x1 vs v(1) tran1.xmem.x1 vs tran1.v(1) tran2.xmem.x1 vs tran2.v(1) retraceplot title 'Memristor with threshold: resistance'
* current through resistor for all plots versus voltage * current through resistor for all plots versus voltage
plot i(v1) vs v(1) tran1.i(v1) vs tran1.v(1) tran2.i(v1) vs tran2.v(1) title 'Memristor with threshold: external current loops'
plot i(v1) vs v(1) tran1.i(v1) vs tran1.v(1) tran2.i(v1) vs tran2.v(1) retraceplot title 'Memristor with threshold: external current loops'
.endc .endc
.end .end

8
examples/memristor/memristor_x.sp

@ -47,11 +47,11 @@ Rmem plus minus r={V(x)}
op op
print all print all
ac lin 101 1 100k ac lin 101 1 100k
plot v(11)
*plot v(11)
* approx. 100 simulation points * approx. 100 simulation points
let deltime = stime/100 let deltime = stime/100
tran $&deltime $&stime uic tran $&deltime $&stime uic
* plot i(v1) vs v(1)
*plot i(v1) vs v(1) retrace
*** you may just stop here *** *** you may just stop here ***
* raise the frequency * raise the frequency
let newfreq = 1.2/stime let newfreq = 1.2/stime
@ -75,9 +75,9 @@ let res2 = tran2.v(1)/(tran2.I(v1) + 1e-16)
settype impedance res res1 res2 settype impedance res res1 res2
plot res vs time res1 vs tran1.time res2 vs tran2.time title 'Memristor with threshold: resistance' plot res vs time res1 vs tran1.time res2 vs tran2.time title 'Memristor with threshold: resistance'
* resistance versus voltage (change occurs only above threshold!) * resistance versus voltage (change occurs only above threshold!)
plot res vs v(1) res1 vs tran1.v(1) res2 vs tran2.v(1) title 'Memristor with threshold: resistance'
plot res vs v(1) res1 vs tran1.v(1) res2 vs tran2.v(1) retraceplot title 'Memristor with threshold: resistance'
* current through resistor for all plots versus voltage * current through resistor for all plots versus voltage
plot i(v1) vs v(1) tran1.i(v1) vs tran1.v(1) tran2.i(v1) vs tran2.v(1) title 'Memristor with threshold: external current loops'
plot i(v1) vs v(1) tran1.i(v1) vs tran1.v(1) tran2.i(v1) vs tran2.v(1) retraceplot title 'Memristor with threshold: external current loops'
.endc .endc
.end .end

2
src/frontend/plotting/gnuplot.c

@ -319,7 +319,7 @@ void ft_gnuplot(double *xlims, double *ylims,
(void) fclose(file); (void) fclose(file);
/* Write out the data and setup arrays */ /* Write out the data and setup arrays */
bool mono = (plottype == PLOT_MONOLIN);
bool mono = (plottype != PLOT_RETLIN);
dir = 0; dir = 0;
prev_xval = NAN; prev_xval = NAN;
for (i = 0; i < scale->v_length; i++) { for (i = 0; i < scale->v_length; i++) {

2
src/frontend/plotting/plotcurv.c

@ -130,7 +130,7 @@ ft_graf(struct dvec *v, struct dvec *xs, bool nostart)
* interpolation. * interpolation.
*/ */
if ((degree == 1) && (gridsize == 0)) { if ((degree == 1) && (gridsize == 0)) {
bool mono = (currentgraph->plottype == PLOT_MONOLIN);
bool mono = (currentgraph->plottype != PLOT_RETLIN);
dir = 0; dir = 0;
for (i = 0, j = v->v_length; i < j; i++) { for (i = 0, j = v->v_length; i < j; i++) {
dx = isreal(xs) ? xs->v_realdata[i] : dx = isreal(xs) ? xs->v_realdata[i] :

10
src/frontend/plotting/plotit.c

@ -600,14 +600,14 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
pfound = TRUE; pfound = TRUE;
} }
} }
if (getflag(wl, "noretraceplot")) {
if (getflag(wl, "retraceplot")) {
if (pfound) { if (pfound) {
fprintf(cp_err, fprintf(cp_err,
"Warning: too many plot types given. " "Warning: too many plot types given. "
"\"noretraceplot\" is ignored.\n");
"\"retraceplot\" is ignored.\n");
} }
else { else {
ptype = PLOT_MONOLIN;
ptype = PLOT_RETLIN;
pfound = TRUE; pfound = TRUE;
} }
} }
@ -640,8 +640,8 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
if (eq(buf, "linplot")) { if (eq(buf, "linplot")) {
ptype = PLOT_LIN; ptype = PLOT_LIN;
} }
else if (eq(buf, "noretraceplot")) {
ptype = PLOT_MONOLIN;
else if (eq(buf, "retraceplot")) {
ptype = PLOT_RETLIN;
} }
else if (eq(buf, "combplot")) { else if (eq(buf, "combplot")) {
ptype = PLOT_COMB; ptype = PLOT_COMB;

2
src/include/ngspice/dvec.h

@ -22,7 +22,7 @@ enum dvec_flags {
/* Plot types. */ /* Plot types. */
typedef enum { typedef enum {
PLOT_LIN, PLOT_COMB, PLOT_POINT, PLOT_MONOLIN
PLOT_LIN, PLOT_COMB, PLOT_POINT, PLOT_RETLIN
} PLOTTYPE; } PLOTTYPE;

Loading…
Cancel
Save