diff --git a/src/frontend/Makefile.am b/src/frontend/Makefile.am index c7936e4b6..c6dbcac37 100644 --- a/src/frontend/Makefile.am +++ b/src/frontend/Makefile.am @@ -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 \ diff --git a/src/frontend/commands.c b/src/frontend/commands.c index 027b9a0d9..b872e708b 100644 --- a/src/frontend/commands.c +++ b/src/frontend/commands.c @@ -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, diff --git a/src/frontend/plotting/Makefile.am b/src/frontend/plotting/Makefile.am index d641bd116..8babe5fc0 100644 --- a/src/frontend/plotting/Makefile.am +++ b/src/frontend/plotting/Makefile.am @@ -9,6 +9,8 @@ libplotting_la_SOURCES = \ clip.h \ gnuplot.c \ gnuplot.h \ + pyplot.c \ + pyplot.h \ graf.c \ graf.h \ graphdb.c \ diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index c54d81f3f..a874170f6 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -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 */