Adds a 'pyplot' interactive command that renders simulated vectors with

matplotlib -- a Python counterpart to ngspice's 'gnuplot' command. Same
syntax (pyplot <file> <plot expressions...>): the first word is the output file name only when it is NOT a plot expression, the rest are ordinary plot expressions handled by plotit().

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Meisam 2026-07-17 11:20:24 +02:00 committed by Holger Vogt
parent 39c662c12b
commit 133f118c66
4 changed files with 28 additions and 0 deletions

View File

@ -41,6 +41,8 @@ libfte_la_SOURCES = \
com_ghelp.h \
com_gnuplot.h \
com_gnuplot.c \
com_pyplot.h \
com_pyplot.c \
com_hardcopy.c \
com_hardcopy.h \
com_help.c \

View File

@ -48,6 +48,7 @@
#include "com_plot.h"
#include "com_setscale.h"
#include "com_gnuplot.h"
#include "com_pyplot.h"
#include "com_state.h"
#include "com_chdir.h"
#include "com_echo.h"
@ -212,6 +213,10 @@ struct comm spcp_coms[] = {
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 2, LOTS,
NULL,
"file plotargs : Send plot to gnuplot." } ,
{ "pyplot", com_pyplot, FALSE, TRUE,
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS,
NULL,
"[file] plotargs : Send plot to matplotlib (file name optional)." } ,
{ "wrdata", com_write_simple, FALSE, TRUE,
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 2, NLOTS,
NULL,
@ -759,6 +764,10 @@ struct comm nutcp_coms[] = {
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 2, LOTS,
NULL,
"file plotargs : Send plot to gnuplot." } ,
{ "pyplot", com_pyplot, FALSE, TRUE,
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS,
NULL,
"[file] plotargs : Send plot to matplotlib (file name optional)." } ,
{ "wrdata", com_write_simple, FALSE, TRUE,
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 2, NLOTS,
NULL,

View File

@ -9,6 +9,8 @@ libplotting_la_SOURCES = \
clip.h \
gnuplot.c \
gnuplot.h \
pyplot.c \
pyplot.h \
graf.c \
graf.h \
graphdb.c \

View File

@ -15,6 +15,7 @@
#include "points.h"
#include "agraf.h"
#include "gnuplot.h"
#include "pyplot.h"
#include "graf.h"
static bool sameflag;
@ -1228,6 +1229,20 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
goto quit;
}
if (devname && eq(devname, "pyplot")) {
/* Enhancement-94: interface to matplotlib */
ft_pyplot(xlims, ylims,
xdelta ? *xdelta : 0.0,
ydelta ? *ydelta : 0.0,
hcopy,
title ? title : vecs->v_plot->pl_title,
xlabel ? xlabel : ft_typabbrev(vecs->v_scale->v_type),
ylabel ? ylabel : ft_typabbrev(y_type),
gtype, ptype, vecs);
rtn = TRUE;
goto quit;
}
#ifdef TCL_MODULE
if (devname && eq(devname, "blt")) {
/* Just send the pairs to Tcl/Tk */