From b4e14d4eb89066f8828687cd2fd45acf1333025f Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 28 May 2023 10:45:26 +0200 Subject: [PATCH 001/128] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f22a84..558cde9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Extended GNUPlot wrapper ======================== -This is a modification of the gnuplot_i library by N.Devillard, which enables the following functionality: +This is a modification of the gnuplot_i library by Nicolas Devillard, which enables the following functionality: * 3D plots, using gnuplot_splot(handle,x,y,z,n,"title"); * Setting z-axis labels with gnuplot_set_zlabel(handle,"z-axis label"); From 731e285051c11e1e57a2d87e377818db3b952d4d Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 28 May 2023 10:45:48 +0200 Subject: [PATCH 002/128] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 558cde9..5754c05 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Extended GNUPlot wrapper ======================== -This is a modification of the gnuplot_i library by Nicolas Devillard, which enables the following functionality: +This is a modification of the `gnuplot_i` library by Nicolas Devillard, which enables the following functionality: * 3D plots, using gnuplot_splot(handle,x,y,z,n,"title"); * Setting z-axis labels with gnuplot_set_zlabel(handle,"z-axis label"); From ceee01eb8c0a70145bb88e326cb592c0c5942a03 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 28 May 2023 10:47:43 +0200 Subject: [PATCH 003/128] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5754c05..de8a54f 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,12 @@ Extended GNUPlot wrapper This is a modification of the `gnuplot_i` library by Nicolas Devillard, which enables the following functionality: -* 3D plots, using gnuplot_splot(handle,x,y,z,n,"title"); -* Setting z-axis labels with gnuplot_set_zlabel(handle,"z-axis label"); -* Production of colour PostScript files with gnuplot_hardcopy_colour(handle,"graph.ps"); -* Windows support - added in September 2005. -* Plotting of complex structures through the use of callbacks - see gnuplot_plot_obj_xy and gnuplot_splot_obj in gnuplot_i.c. -* Contour plotting, using gnuplot_setstyle(handle,"lines");gnuplot_contour_plot(handle,x,y,z,nx,ny,"title"); +* 3D plots, using `gnuplot_splot(handle, x, y, z, n, "title")` +* Setting z-axis labels with `gnuplot_set_zlabel(handle, "z-axis label")` +* Production of colour PostScript files with `gnuplot_hardcopy_colour(handle, "graph.ps")` +* Windows support, added in September 2005 +* Plotting of complex structures through the use of callbacks, see `gnuplot_plot_obj_xy` and `gnuplot_splot_obj` +* Contour plotting, using `gnuplot_setstyle(handle, "lines")` and `gnuplot_contour_plot(handle, x, y, z, nx, ny, "title")` If you have any questions or comments, these can be sent to robert.bradley@merton.oxon.org, or via my website (http://www.robert-bradley.co.uk). From 8050c3b4fad047c86b3a1f487981dc8184703ebb Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 28 May 2023 17:03:34 +0200 Subject: [PATCH 004/128] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index de8a54f..09cb65d 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -Extended GNUPlot wrapper -======================== +gnuplot interface to C +====================== -This is a modification of the `gnuplot_i` library by Nicolas Devillard, which enables the following functionality: +This is a modification of the `gnuplot_i` library by Nicolas Devillard, which adds the following functionality: * 3D plots, using `gnuplot_splot(handle, x, y, z, n, "title")` -* Setting z-axis labels with `gnuplot_set_zlabel(handle, "z-axis label")` -* Production of colour PostScript files with `gnuplot_hardcopy_colour(handle, "graph.ps")` +* Set z-axis labels with `gnuplot_set_zlabel(handle, "z-axis label")` +* Produce color PostScript files with `gnuplot_hardcopy_colour(handle, "graph.ps")` * Windows support, added in September 2005 -* Plotting of complex structures through the use of callbacks, see `gnuplot_plot_obj_xy` and `gnuplot_splot_obj` +* Plot complex structures through the use of callbacks, see `gnuplot_plot_obj_xy` and `gnuplot_splot_obj` * Contour plotting, using `gnuplot_setstyle(handle, "lines")` and `gnuplot_contour_plot(handle, x, y, z, nx, ny, "title")` If you have any questions or comments, these can be sent to robert.bradley@merton.oxon.org, or via my website (http://www.robert-bradley.co.uk). From b95eeb1ca88c15840900e5d878f7fa329d0e9663 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Mon, 29 May 2023 08:49:36 +0200 Subject: [PATCH 005/128] Update gnuplot_i.c * Refactoring * Variable naming improvements * Code comment review * Stylistic improvements: removal of tabs, indentation, placement of braces --- gnuplot_i.c | 1826 ++++++++++++++++++++++----------------------------- 1 file changed, 794 insertions(+), 1032 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index 91b0d7c..426bd3c 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -1,45 +1,44 @@ #ifndef _GNUPLOT_PIPES_C_ #define _GNUPLOT_PIPES_C_ + /*-------------------------------------------------------------------------*/ /** - @file gnuplot_i.c - @author N. Devillard (parts R. Bradley) - @date Sep 1998, Oct 2004, Sept 2005, Nov 2005, Apr 2006 - @version $Revision: 2.10.3 $ - @brief C interface to gnuplot. - - gnuplot is a freely available, command-driven graphical display tool for - Unix. It compiles and works quite well on a number of Unix flavours as - well as other operating systems. The following module enables sending - display requests to gnuplot through simple C calls. - - 3D and colour printing extensions added October 2004 by Robert Bradley + @file gnuplot_i.c + @author N. Devillard (parts R. Bradley) + @date Sep 1998, Oct 2004, Sept 2005, Nov 2005, Apr 2006 + @version $Revision: 2.10.3 $ + @brief C interface to gnuplot. + + gnuplot is an open-source, command-driven graphical display tool for Unix. + It compiles and works quite well on a number of Unix flavours as well as + other operating systems. The following module enables sending display + requests to gnuplot through C calls. + + 3D and color printing extensions added Oct 2004 by Robert Bradley (robert.bradley@merton.ox.ac.uk), based on existing code: - - gnuplot_splot (plot 3D graph), gnuplot_set_zlabel (set the z axis label for 3D plots), - gnuplot_hardcopy_colour (for printing in colour) - - OS X and limited Windows support added 11-13th September 2005: - - On Windows, pgnuplot and wgnuplot.exe must be in the current directory. - On OS X, if DISPLAY environment variable is not set, or USE_AQUA=1, aqua is - used instead of x11. - gnuplot_setterm also added to allow the terminal type to be set. - - gnuplot_plot_obj_xy added 15th September 2005 - plotting data from arbitrary - structures using callback functions - gnuplot_contour_plot added 23rd November 2005 (plots contours, use + + gnuplot_splot (plot a 3D graph) + gnuplot_hardcopy (for printing in color) + + OS X and limited Windows support added 11-13 Sep 2005: + - On Windows, pgnuplot and wgnuplot.exe must be in the current directory. + - On OS X, if DISPLAY environment variable is not set, or USE_AQUA=1, aqua is + used instead of x11. + - gnuplot_setterm added to allow the terminal type to be set. + + gnuplot_plot_obj_xy added 15 Sep 2005 (plots data from arbitrary + structures using callback functions) + gnuplot_contour_plot added 23 Nov 2005 (plots contours, use gnuplot_setstyle to set the contour style) - - gnuplot_splot_grid added 2nd April 2006 - plots 2D grids of data [x,y] + gnuplot_splot_grid added 2 Apr 2006 (plots 2D grids of data [x,y]) */ /*--------------------------------------------------------------------------*/ /* - $Id: gnuplot_i.c,v 2.10 2003/01/27 08:58:04 ndevilla Exp $ - $Author: ndevilla $ - $Date: 2003/01/27 08:58:04 $ - $Revision: 2.10.2 $ + $Id: gnuplot_i.c,v 2.10 2003/01/27 08:58:04 ndevilla Exp $ + $Author: ndevilla $ + $Date: 2003/01/27 08:58:04 $ + $Revision: 2.10.2 $ */ /*--------------------------------------------------------------------------- @@ -53,18 +52,18 @@ ---------------------------------------------------------------------------*/ /** Maximal size of a gnuplot command */ -#define GP_CMD_SIZE 2048 +#define GP_CMD_SIZE 2048 /** Maximal size of a plot title */ -#define GP_TITLE_SIZE 80 +#define GP_TITLE_SIZE 80 /** Maximal size for an equation */ -#define GP_EQ_SIZE 512 +#define GP_EQ_SIZE 512 /** Maximal size of a name in the PATH */ -#define PATH_MAXNAMESZ 4096 +#define PATH_MAXNAMESZ 4096 #ifdef _WIN32 #undef P_tmpdir #endif -/** Define P_tmpdir if not defined (this is normally a POSIX symbol) */ +/** Define P_tmpdir if not defined; this is normally a POSIX symbol */ #ifndef P_tmpdir #define P_tmpdir "." #endif @@ -84,41 +83,39 @@ #include #include -int mkstemp(char* templ) { - srand(time(NULL)); - int i; - char *start=strstr(templ, "XXXXXX"); - for (i=0;i<6;i++) { - start[i]=(char) (48+((int) rand()*10/32768.0)); - } - //while ((start=strchr(templ, '/'))!=NULL) {start[0]='-';} - //printf("Opening %s...\n",templ); - i=open(templ,O_RDWR | O_CREAT); - if (i!=-1) { - DWORD dwFileAttr=GetFileAttributes(templ); - SetFileAttributes(templ,dwFileAttr & !FILE_ATTRIBUTE_READONLY); - } - return i; +int mkstemp (char *templ) { + srand(time(NULL)); + int i; + char *start = strstr(templ, "XXXXXX"); + + for (i = 0; i < 6; i++) { + start[i] = (char) (48 + ((int) rand() * 10 / 32768.0)); + } + i = open(templ, O_RDWR | O_CREAT); + if (i != -1) { + DWORD dwFileAttr = GetFileAttributes(templ); + SetFileAttributes(templ, dwFileAttr & !FILE_ATTRIBUTE_READONLY); + } + return i; } #endif /*-------------------------------------------------------------------------*/ /** - @brief Find out where a command lives in your PATH. - @param pname Name of the program to look for. - @return pointer to statically allocated character string. + @brief Find out where a command lives in your PATH. + @param pname Name of the program to look for. + @return pointer to statically allocated character string. This is the C equivalent to the 'which' command in Unix. It parses - out your PATH environment variable to find out where a command - lives. The returned character string is statically allocated within - this function, i.e. there is no need to free it. Beware that the - contents of this string will change from one call to the next, - though (as all static variables in a function). + your PATH environment variable to find out where a command lives. + The returned character string is statically allocated within this function, + i.e. there is no need to free it. + Note that the contents of this string will change from one call to the next, + similar to all static variables in a function. The input character string must be the name of a command without prefixing path of any kind, i.e. only the command name. The returned - string is the path in which a command matching the same name was - found. + string is the path in which a command matching the same name was found. Examples (assuming there is a prog named 'hello' in the cwd): @@ -128,60 +125,59 @@ int mkstemp(char* templ) { gnuplot_get_program_path("csh") returns "/usr/bin" gnuplot_get_program_path("/bin/ls") returns NULL @endverbatim - + */ /*-------------------------------------------------------------------------*/ -char * gnuplot_get_program_path(char * pname) -{ - int i, j, lg; - char * path; - static char buf[PATH_MAXNAMESZ]; - - /* Trivial case: try in CWD */ - sprintf(buf, "./%s", pname) ; - if (access(buf, X_OK)==0) { - sprintf(buf, "."); - return buf ; - } - /* Try out in all paths given in the PATH variable */ - buf[0] = 0; - path = getenv("PATH") ; - if (path!=NULL) { - for (i=0; path[i]; ) { - for (j=i ; (path[j]) && (path[j]!=':') ; j++); - lg = j - i; - strncpy(buf, path + i, lg); - if (lg == 0) buf[lg++] = '.'; - buf[lg++] = '/'; - strcpy(buf + lg, pname); - if (access(buf, X_OK) == 0) { - /* Found it! */ - break ; - } - buf[0] = 0; - i = j; - if (path[i] == ':') i++ ; - } - } else { - fprintf(stderr, "PATH variable not set\n"); - } - /* If the buffer is still empty, the command was not found */ - if (buf[0] == 0) return NULL ; - /* Otherwise truncate the command name to yield path only */ - lg = strlen(buf) - 1 ; - while (buf[lg]!='/') { - buf[lg]=0 ; - lg -- ; +char *gnuplot_get_program_path (char *pname) { + int i, j, lg; + char *path; + static char buf[PATH_MAXNAMESZ]; + + /* Trivial case: try in current working directory */ + sprintf(buf, "./%s", pname); + if (access(buf, X_OK) == 0) { + sprintf(buf, "."); + return buf; + } + + /* Try out in all paths given in the PATH variable */ + buf[0] = 0; + path = getenv("PATH"); + if (path != NULL) { + for (i = 0; path[i]; ) { + for (j = i; (path[j]) && (path[j] != ':'); j++); + lg = j - i; + strncpy(buf, path + i, lg); + if (lg == 0) buf[lg++] = '.'; + buf[lg++] = '/'; + strcpy(buf + lg, pname); + if (access(buf, X_OK) == 0) /* Found it! */ break; + buf[0] = 0; + i = j; + if (path[i] == ':') i++; } + } else { + fprintf(stderr, "PATH variable not set\n"); + } + + /* If the buffer is still empty, the command was not found */ + if (buf[0] == 0) return NULL; + + /* Otherwise truncate the command name to yield path only */ + lg = strlen(buf) - 1; + while (buf[lg] != '/') { buf[lg] = 0; - return buf ; + lg --; + } + buf[lg] = 0; + return buf; } /*-------------------------------------------------------------------------*/ /** - @brief Opens up a gnuplot session, ready to receive commands. - @return Newly allocated gnuplot control structure. + @brief Opens up a gnuplot session, ready to receive commands. + @return Newly allocated gnuplot control structure. This opens up a new gnuplot session, ready for input. The struct controlling a gnuplot session should remain opaque and only be @@ -191,59 +187,56 @@ char * gnuplot_get_program_path(char * pname) */ /*--------------------------------------------------------------------------*/ -gnuplot_ctrl * gnuplot_init(void) -{ - gnuplot_ctrl * handle ; +gnuplot_ctrl *gnuplot_init (void) { + gnuplot_ctrl *handle; #ifndef _WIN32 #ifndef __APPLE__ - if (getenv("DISPLAY") == NULL) { - fprintf(stderr, "cannot find DISPLAY variable: is it set?\n") ; - } + if (getenv("DISPLAY") == NULL) { + fprintf(stderr, "Cannot find DISPLAY variable: is it set?\n"); + } #endif #endif #ifndef _WIN32 - if (gnuplot_get_program_path("gnuplot")==NULL) { - fprintf(stderr, "cannot find gnuplot in your PATH"); - return NULL ; - } + if (gnuplot_get_program_path("gnuplot") == NULL) { + fprintf(stderr, "Cannot find gnuplot in your PATH"); + return NULL; + } #endif - if (gnuplot_get_program_path(GNUPLOT_EXEC)==NULL) { - fprintf(stderr, "cannot find gnuplot in your PATH"); - return NULL ; - } - - /* - * Structure initialization: - */ - handle = (gnuplot_ctrl*)malloc(sizeof(gnuplot_ctrl)) ; - handle->nplots = 0 ; - gnuplot_setstyle(handle, "points") ; - handle->ntmp = 0 ; - handle->gnucmd = popen(GNUPLOT_EXEC, "w") ; - if (handle->gnucmd == NULL) { - fprintf(stderr, "error starting gnuplot\n") ; - free(handle) ; - return NULL ; - } + if (gnuplot_get_program_path(GNUPLOT_EXEC) == NULL) { + fprintf(stderr, "Cannot find gnuplot in your PATH"); + return NULL; + } + + /* Structure initialization: */ + handle = (gnuplot_ctrl *)malloc(sizeof(gnuplot_ctrl)); + handle->nplots = 0; + gnuplot_setstyle(handle, "points"); + handle->ntmp = 0; + handle->gnucmd = popen(GNUPLOT_EXEC, "w"); + if (handle->gnucmd == NULL) { + fprintf(stderr, "Error starting gnuplot\n"); + free(handle); + return NULL; + } #ifdef _WIN32 - gnuplot_setterm(handle,"windows"); + gnuplot_setterm(handle, "windows"); #elif __APPLE__ - // Try to determine whether we should use aqua or x11 as our default - if (getenv("DISPLAY") == NULL || (getenv("USE_AQUA")!=NULL && strcmp(getenv("USE_AQUA"),"1")>=0)) - gnuplot_setterm(handle,"aqua"); - else - gnuplot_setterm(handle,"x11"); + /* Determine whether we should use aqua or x11 as our default */ + if (getenv("DISPLAY") == NULL || (getenv("USE_AQUA") != NULL && strcmp(getenv("USE_AQUA"), "1") >= 0)) + gnuplot_setterm(handle, "aqua"); + else + gnuplot_setterm(handle, "x11"); #else - gnuplot_setterm(handle,"x11"); + gnuplot_setterm(handle, "x11"); #endif - return handle; + return handle; } /*-------------------------------------------------------------------------*/ /** - @brief Closes a gnuplot session previously opened by gnuplot_init() - @param handle Gnuplot session control handle. - @return void + @brief Closes a gnuplot session previously opened by gnuplot_init() + @param handle Gnuplot session control handle. + @return void Kills the child PID and deletes all opened temporary files. It is mandatory to call this function to close the handle, otherwise @@ -252,39 +245,34 @@ gnuplot_ctrl * gnuplot_init(void) */ /*--------------------------------------------------------------------------*/ -void gnuplot_close(gnuplot_ctrl * handle) -{ - int i ; - - if (pclose(handle->gnucmd) == -1) { - fprintf(stderr, "problem closing communication to gnuplot\n") ; - return ; - } - if (handle->ntmp) { - for (i=0 ; intmp ; i++) { +void gnuplot_close (gnuplot_ctrl *handle) { + if (pclose(handle->gnucmd) == -1) { + fprintf(stderr, "Cannot close communication to gnuplot\n"); + return; + } + if (handle->ntmp) { + for (int i = 0; i < handle->ntmp; i++) { #ifdef _WIN32 - int x=remove(handle->to_delete[i]) ; - if (x) - printf("Failure to delate %s: error number %d\n",handle->to_delete[i],errno); + int x = remove(handle->to_delete[i]); + if (x) + printf("Cannot delete %s: error number %d\n", handle->to_delete[i], errno); #else - remove(handle->to_delete[i]); + remove(handle->to_delete[i]); #endif - } } - free(handle) ; - return ; + } + free(handle); + return; } - /*-------------------------------------------------------------------------*/ /** - @brief Sends a command to an active gnuplot session. - @param handle Gnuplot session control handle - @param cmd Command to send, same as a printf statement. + @brief Sends a command to an active gnuplot session. + @param handle Gnuplot session control handle + @param cmd Command to send, same as a printf statement. This sends a string to an active gnuplot session, to be executed. - There is strictly no way to know if the command has been - successfully executed or not. + There is no way to know if the command has been successfully executed or not. The command syntax is the same as printf. Examples: @@ -294,40 +282,33 @@ void gnuplot_close(gnuplot_ctrl * handle) gnuplot_cmd(g, "plot %g * cos(%g * x)", 32.0, -3.0); @endcode - Since the communication to the gnuplot process is run through - a standard Unix pipe, it is only unidirectional. This means that - it is not possible for this interface to query an error status - back from gnuplot. + Since the communication to the gnuplot process is run through a standard Unix + pipe, it is only unidirectional. This means that it is not possible for this + interface to query an error status back from gnuplot. */ /*--------------------------------------------------------------------------*/ -void gnuplot_cmd(gnuplot_ctrl * handle, char * cmd, ...) -{ - va_list ap ; - char local_cmd[GP_CMD_SIZE]; - - va_start(ap, cmd); - vsprintf(local_cmd, cmd, ap); - va_end(ap); - - strcat(local_cmd, "\n"); - - fputs(local_cmd, handle->gnucmd) ; - fflush(handle->gnucmd); - return ; +void gnuplot_cmd (gnuplot_ctrl *handle, char *cmd, ...) { + va_list ap; + char local_cmd[GP_CMD_SIZE]; + + va_start(ap, cmd); + vsprintf(local_cmd, cmd, ap); + va_end(ap); + strcat(local_cmd, "\n"); + fputs(local_cmd, handle->gnucmd); + fflush(handle->gnucmd); + return; } - /*-------------------------------------------------------------------------*/ /** - @brief Change the plotting style of a gnuplot session. - @param h Gnuplot session control handle - @param plot_style Plotting-style to use (character string) - @return void - - The provided plotting style is a character string. It must be one of - the following: + @brief Change the plotting style of a gnuplot session. + @param handle Gnuplot session control handle + @param plot_style Plotting-style to use (character string) + @return void + The provided plotting style is one of the following character strings: - lines - points - linespoints @@ -340,142 +321,94 @@ void gnuplot_cmd(gnuplot_ctrl * handle, char * cmd, ...) */ /*--------------------------------------------------------------------------*/ -void gnuplot_setstyle(gnuplot_ctrl * h, char * plot_style) -{ - if (strcmp(plot_style, "lines") && - strcmp(plot_style, "points") && - strcmp(plot_style, "linespoints") && - strcmp(plot_style, "impulses") && - strcmp(plot_style, "dots") && - strcmp(plot_style, "steps") && - strcmp(plot_style, "errorbars") && - strcmp(plot_style, "boxes") && - strcmp(plot_style, "boxerrorbars")) { - fprintf(stderr, "warning: unknown requested style: using points\n") ; - strcpy(h->pstyle, "points") ; - } else { - strcpy(h->pstyle, plot_style) ; - } - return ; -} - -/*-------------------------------------------------------------------------*/ -/** - @brief Change the terminal of a gnuplot session. - @param h Gnuplot session control handle - @param terminal Terminal name (character string) - @return void - - No attempt is made to check the validity of the terminal name. This function - simply makes a note of it and calls gnuplot_cmd to change the name - */ -/*--------------------------------------------------------------------------*/ - -void gnuplot_setterm(gnuplot_ctrl * h, char * terminal) -{ - char cmd[64]; - strncpy(h->term, terminal,32); - h->term[31]=0; - sprintf(cmd,"set terminal %s",h->term); - gnuplot_cmd(h,cmd); -} - - -/*-------------------------------------------------------------------------*/ -/** - @brief Sets the x label of a gnuplot session. - @param h Gnuplot session control handle. - @param label Character string to use for X label. - @return void - - Sets the x label for a gnuplot session. - */ -/*--------------------------------------------------------------------------*/ - -void gnuplot_set_xlabel(gnuplot_ctrl * h, char * label) -{ - char cmd[GP_CMD_SIZE] ; - - sprintf(cmd, "set xlabel \"%s\"", label) ; - gnuplot_cmd(h, cmd) ; - return ; +void gnuplot_setstyle (gnuplot_ctrl *handle, char *plot_style) { + if (strcmp(plot_style, "lines") && + strcmp(plot_style, "points") && + strcmp(plot_style, "linespoints") && + strcmp(plot_style, "impulses") && + strcmp(plot_style, "dots") && + strcmp(plot_style, "steps") && + strcmp(plot_style, "errorbars") && + strcmp(plot_style, "boxes") && + strcmp(plot_style, "boxerrorbars")) { + fprintf(stderr, "Warning: unknown requested style: using 'points'\n"); + strcpy(handle->pstyle, "points"); + } else { + strcpy(handle->pstyle, plot_style); + } + return; } - /*-------------------------------------------------------------------------*/ /** - @brief Sets the y label of a gnuplot session. - @param h Gnuplot session control handle. - @param label Character string to use for Y label. - @return void + @brief Change the terminal of a gnuplot session. + @param handle Gnuplot session control handle + @param terminal Terminal name (character string) + @return void - Sets the y label for a gnuplot session. + No attempt is made to check the validity of the terminal name. This function + simply makes a note of it and calls gnuplot_cmd to change the name. */ /*--------------------------------------------------------------------------*/ -void gnuplot_set_ylabel(gnuplot_ctrl * h, char * label) -{ - char cmd[GP_CMD_SIZE] ; +void gnuplot_setterm (gnuplot_ctrl *handle, char *terminal) { + char cmd[64]; - sprintf(cmd, "set ylabel \"%s\"", label) ; - gnuplot_cmd(h, cmd) ; - return ; + strncpy(handle->term, terminal, 32); + handle->term[31] = 0; + sprintf(cmd, "set terminal %s", handle->term); + gnuplot_cmd(handle, cmd); } /*-------------------------------------------------------------------------*/ /** - @brief Sets the z label of a gnuplot session. - @param h Gnuplot session control handle. - @param label Character string to use for Z label. - @return void + @brief Sets the axis label of a gnuplot session. + @param handle Gnuplot session control handle. + @param label Character string to use for axis label. + @param axis Character string to to identify axis, ie 'x', 'y' or 'z'. + @return void - Sets the z label for a gnuplot session. (Added by Robert Bradley 12 October 2004) + Sets the axis label for a gnuplot session. */ /*--------------------------------------------------------------------------*/ -void gnuplot_set_zlabel(gnuplot_ctrl * h, char * label) -{ - char cmd[GP_CMD_SIZE] ; +void gnuplot_set_axislabel (gnuplot_ctrl *handle, char *label, char *axis) { + char cmd[GP_CMD_SIZE]; - sprintf(cmd, "set zlabel \"%s\"", label) ; - gnuplot_cmd(h, cmd) ; - return ; + sprintf(cmd, "set %slabel \"%s\"", axis, label); + gnuplot_cmd(handle, cmd); + return; } /*-------------------------------------------------------------------------*/ /** - @brief Resets a gnuplot session (next plot will erase previous ones). - @param h Gnuplot session control handle. - @return void + @brief Resets a gnuplot session (next plot will erase previous ones). + @param handle Gnuplot session control handle. + @return void - Resets a gnuplot session, i.e. the next plot will erase all previous - ones. + Resets a gnuplot session, i.e. the next plot will erase all previous ones. */ /*--------------------------------------------------------------------------*/ -void gnuplot_resetplot(gnuplot_ctrl * h) -{ - int i ; - if (h->ntmp) { - for (i=0 ; intmp ; i++) { - remove(h->to_delete[i]) ; - } +void gnuplot_resetplot (gnuplot_ctrl *handle) { + if (handle->ntmp) { + for (int i = 0; i < handle->ntmp; i++) { + remove(handle->to_delete[i]); } - h->ntmp = 0 ; - h->nplots = 0 ; - return ; + } + handle->ntmp = 0; + handle->nplots = 0; + return; } - - /*-------------------------------------------------------------------------*/ /** - @brief Plots a 2d graph from a list of doubles. - @param handle Gnuplot session control handle. - @param d Array of doubles. - @param n Number of values in the passed array. - @param title Title of the plot. - @return void + @brief Plots a 2d graph from a list of doubles. + @param handle Gnuplot session control handle. + @param d Array of doubles. + @param n Number of values in the passed array. + @param title Title of the plot. + @return void Plots out a 2d graph from a list of doubles. The x-coordinate is the index of the double in the list, the y coordinate is the double in @@ -484,861 +417,690 @@ void gnuplot_resetplot(gnuplot_ctrl * h) Example: @code - gnuplot_ctrl *h ; - double d[50] ; - int i ; + gnuplot_ctrl *h; + double d[50]; - h = gnuplot_init() ; - for (i=0 ; i<50 ; i++) { - d[i] = (double)(i*i) ; + h = gnuplot_init(); + for (int i = 0; i < 50; i++) { + d[i] = (double)(i*i); } - gnuplot_plot_x(h, d, 50, "parabola") ; - sleep(2) ; - gnuplot_close(h) ; + gnuplot_plot_x(h, d, 50, "parabola"); + sleep(2); + gnuplot_close(h); @endcode */ /*--------------------------------------------------------------------------*/ -void gnuplot_plot_x( - gnuplot_ctrl * handle, - double * d, - int n, - char * title -) -{ - int i ; - int tmpfd ; - char name[128] ; - char cmd[GP_CMD_SIZE] ; - char line[GP_CMD_SIZE] ; - - - if (handle==NULL || d==NULL || (n<1)) return ; - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, - "maximum # of temporary files reached (%d): cannot open more", - GP_MAX_TMP_FILES) ; - return ; - } - - /* Open temporary file for output */ - sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd=mkstemp(name))==-1) { - fprintf(stderr,"cannot create temporary file: exiting plot") ; - return ; - } - - /* Store file name in array for future deletion */ - strcpy(handle->to_delete[handle->ntmp], name) ; - handle->ntmp ++ ; - /* Write data to this file */ - for (i=0 ; inplots > 0) { - strcpy(cmd, "replot") ; - } else { - strcpy(cmd, "plot") ; - } - - if (title == NULL) { - sprintf(line, "%s \"%s\" with %s", cmd, name, handle->pstyle) ; - } else { - sprintf(line, "%s \"%s\" title \"%s\" with %s", cmd, name, - title, handle->pstyle) ; - } - - /* send command to gnuplot */ - gnuplot_cmd(handle, line) ; - handle->nplots++ ; - return ; +void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title) { + int tmpfd; + char name[128]; + char cmd[GP_CMD_SIZE]; + + if (handle == NULL || x == NULL || (n < 1)) return; + + /* Open one more temporary file? */ + if (handle->ntmp == GP_MAX_TMP_FILES - 1) { + fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); + return; + } + + /* Open temporary file for output */ + sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); + if ((tmpfd = mkstemp(name)) == -1) { + fprintf(stderr, "Cannot create temporary file: exiting plot"); + return; + } + + /* Store file name in array for future deletion */ + strcpy(handle->to_delete[handle->ntmp], name); + handle->ntmp++; + + /* Write data to this file */ + for (int i = 0; i < n; i++) { + sprintf(cmd, "%g\n", x[i]); + write(tmpfd, cmd, strlen(cmd)); + } + close(tmpfd); + + /* Command to be sent to gnuplot */ + if (title == NULL) { + sprintf(cmd, "%s \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, handle->pstyle); + } else { + sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, title, handle->pstyle); + } + + /* send command to gnuplot */ + gnuplot_cmd(handle, cmd); + handle->nplots++; + return; } - - /*-------------------------------------------------------------------------*/ /** - @brief Plot a 2d graph from a list of points. - @param handle Gnuplot session control handle. - @param x Pointer to a list of x coordinates. - @param y Pointer to a list of y coordinates. - @param n Number of doubles in x (assumed the same as in y). - @param title Title of the plot. - @return void - - Plots out a 2d graph from a list of points. Provide points through a list - of x and a list of y coordinates. Both provided arrays are assumed to - contain the same number of values. + @brief Plot a 2d graph from a list of points. + @param handle Gnuplot session control handle. + @param x Pointer to a list of x coordinates. + @param y Pointer to a list of y coordinates. + @param n Number of doubles in x (assumed the same as in y). + @param title Title of the plot. + @return void + + Plots a 2d graph from a list of points. + Provide points through a list of x and a list of y coordinates. + Both arrays are assumed to contain the same number of values. @code - gnuplot_ctrl *h ; - double x[50] ; - double y[50] ; - int i ; - - h = gnuplot_init() ; - for (i=0 ; i<50 ; i++) { - x[i] = (double)(i)/10.0 ; - y[i] = x[i] * x[i] ; + gnuplot_ctrl *h; + double x[50], y[50]; + + h = gnuplot_init(); + for (int i = 0; i < 50; i++) { + x[i] = (double)(i)/10.0; + y[i] = x[i] * x[i]; } - gnuplot_plot_xy(h, x, y, 50, "parabola") ; - sleep(2) ; - gnuplot_close(h) ; + gnuplot_plot_xy(h, x, y, 50, "parabola"); + sleep(2); + gnuplot_close(h); @endcode */ /*--------------------------------------------------------------------------*/ -void gnuplot_plot_xy( - gnuplot_ctrl * handle, - double * x, - double * y, - int n, - char * title -) -{ - int i ; - int tmpfd ; - char name[128] ; - char cmd[GP_CMD_SIZE] ; - char line[GP_CMD_SIZE] ; - - if (handle==NULL || x==NULL || y==NULL || (n<1)) return ; - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, - "maximum # of temporary files reached (%d): cannot open more", - GP_MAX_TMP_FILES) ; - return ; - } - - /* Open temporary file for output */ - sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd=mkstemp(name))==-1) { - fprintf(stderr,"cannot create temporary file: exiting plot") ; - return ; - } - /* Store file name in array for future deletion */ - strcpy(handle->to_delete[handle->ntmp], name) ; - handle->ntmp ++ ; - - /* Write data to this file */ - for (i=0 ; inplots > 0) { - strcpy(cmd, "replot") ; - } else { - strcpy(cmd, "plot") ; - } - - if (title == NULL) { - sprintf(line, "%s \"%s\" with %s", cmd, name, handle->pstyle) ; - } else { - sprintf(line, "%s \"%s\" title \"%s\" with %s", cmd, name, - title, handle->pstyle) ; - } - - /* send command to gnuplot */ - gnuplot_cmd(handle, line) ; - handle->nplots++ ; - return ; +void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *title) { + int tmpfd; + char name[128]; + char cmd[GP_CMD_SIZE]; + + if (handle == NULL || x == NULL || y == NULL || (n < 1)) return; + + /* Open one more temporary file? */ + if (handle->ntmp == GP_MAX_TMP_FILES - 1) { + fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); + return; + } + + /* Open temporary file for output */ + sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); + if ((tmpfd = mkstemp(name)) == -1) { + fprintf(stderr, "Cannot create temporary file: exiting plot"); + return; + } + + /* Store file name in array for future deletion */ + strcpy(handle->to_delete[handle->ntmp], name); + handle->ntmp++; + + /* Write data to this file */ + for (int i = 0; i < n; i++) { + sprintf(cmd, "%g %g\n", x[i], y[i]); + write(tmpfd, cmd, strlen(cmd)); + } + close(tmpfd); + + /* Command to be sent to gnuplot */ + if (title == NULL) { + sprintf(cmd, "%s \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, handle->pstyle); + } else { + sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, title, handle->pstyle); + } + + /* send command to gnuplot */ + gnuplot_cmd(handle, cmd); + handle->nplots++; + return; } /*-------------------------------------------------------------------------*/ /** - @brief Plot a 3d graph from a list of points. - @param handle Gnuplot session control handle. - @param x Pointer to a list of x coordinates. - @param y Pointer to a list of y coordinates. - @param z Pointer to a list of z coordinates. - @param n Number of doubles in x (y and z must be the the same). - @param title Title of the plot. - @return void + @brief Plot a 3d graph from a list of points. + @param handle Gnuplot session control handle. + @param x Pointer to a list of x coordinates. + @param y Pointer to a list of y coordinates. + @param z Pointer to a list of z coordinates. + @param n Number of doubles in x (y and z must be the the same). + @param title Title of the plot. + @return int 1 if error encountered, 0 otherwise gnuplot_splot(handle,x,y,z,n,title); Based on gnuplot_plot_xy, modifications by Robert Bradley 12/10/2004 - Plots a 3d graph from a list of points, passed in the form of three arrays x, y and z. All arrays are assumed to - contain the same number of values. + Plots a 3d graph from a list of points, passed as arrays x, y and z. + All arrays are assumed to contain the same number of values. @code - gnuplot_ctrl *h ; - double x[50] ; y[50] ; z[50]; - int i ; - - h = gnuplot_init() ; - for (i=0 ; i<50 ; i++) { - x[i] = (double)(i)/10.0 ; - y[i] = x[i] * x[i] ; - z[i] = x[i] * x[i]/2.0; + gnuplot_ctrl *h; + double x[50], y[50], z[50]; + + h = gnuplot_init(); + for (int i = 0; i < 50; i++) { + x[i] = (double)(i)/10.0; + y[i] = x[i] * x[i]; + z[i] = x[i] * x[i]/2.0; } - gnuplot_splot(h, x, y, z, 50, "parabola") ; - sleep(2) ; - gnuplot_close(h) ; + gnuplot_splot(h, x, y, z, 50, "parabola"); + sleep(2); + gnuplot_close(h); @endcode */ /*--------------------------------------------------------------------------*/ -int gnuplot_splot(gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char *title) { - int i; - int tmpfd ; - char name[128] ; - char cmd[GP_CMD_SIZE] ; - char line[GP_CMD_SIZE] ; - - if (handle==NULL || x==NULL || y==NULL || (n<1)) return 1; - if (handle->nplots > 0) - return 1; - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, - "maximum # of temporary files reached (%d): cannot open more", - GP_MAX_TMP_FILES) ; - return 1; - } - - /* Open temporary file for output */ - sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd=mkstemp(name))==-1) { - fprintf(stderr,"cannot create temporary file: exiting plot") ; - return 1; - } - /* Store file name in array for future deletion */ - strcpy(handle->to_delete[handle->ntmp], name) ; - handle->ntmp ++ ; - - /* Write data to this file */ - for (i=0 ; ipstyle) ; - } else { - sprintf(line, "%s \"%s\" title \"%s\" with %s", cmd, name, - title, handle->pstyle) ; - } - - /* send command to gnuplot */ - gnuplot_cmd(handle, line) ; - handle->nplots++ ; - return 0; +int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char *title) { + int tmpfd; + char name[128]; + char cmd[GP_CMD_SIZE]; + + if (handle == NULL || x == NULL || y == NULL || (n < 1)) return 1; + if (handle->nplots > 0) return 1; + + /* Open one more temporary file? */ + if (handle->ntmp == GP_MAX_TMP_FILES - 1) { + fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); + return 1; + } + + /* Open temporary file for output */ + sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); + if ((tmpfd = mkstemp(name)) == -1) { + fprintf(stderr, "Cannot create temporary file: exiting plot"); + return 1; + } + + /* Store file name in array for future deletion */ + strcpy(handle->to_delete[handle->ntmp], name); + handle->ntmp++; + + /* Write data to this file */ + for (int i = 0; i < n; i++) { + sprintf(cmd, "%g %g %g\n", x[i], y[i], z[i]); + write(tmpfd, cmd, strlen(cmd)); + } + close(tmpfd); + + /* Command to be sent to gnuplot */ + if (title == NULL) { + sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); + } else { + sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); + } + + /* send command to gnuplot */ + gnuplot_cmd(handle, cmd); + handle->nplots++; + return 0; } /*-------------------------------------------------------------------------*/ /** - @brief Plot a 3d graph from a grid of points. - @param handle Gnuplot session control handle. - @param points Pointer to a grid of points (rows,cols). - @param rows Number of rows (y points). - @param cols Number of columns (x points). - @param title Title of the plot. - @return void + @brief Plot a 3d graph from a grid of points. + @param handle Gnuplot session control handle. + @param points Pointer to a grid of points (rows,cols). + @param rows Number of rows (y points). + @param cols Number of columns (x points). + @param title Title of the plot. + @return int 1 if error encountered, 0 otherwise gnuplot_splot_grid(handle,(double*) points,rows,cols,title); Based on gnuplot_splot, modifications by Robert Bradley 2/4/2006 - Plots a 3d graph from a grid of points, passed in the form of a 2D array [x,y]. + Plots a 3d graph from a grid of points, passed in the form of an array [x,y]. */ /*--------------------------------------------------------------------------*/ -int gnuplot_splot_grid(gnuplot_ctrl *handle, double *points, int rows, int cols, char *title) { - int i; - int j; - int tmpfd ; - char name[128] ; - char cmd[GP_CMD_SIZE] ; - char line[GP_CMD_SIZE] ; - - if (handle==NULL || points==NULL || (rows<1) || (cols<1)) return 1; - if (handle->nplots > 0) - return 1; - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, - "maximum # of temporary files reached (%d): cannot open more", - GP_MAX_TMP_FILES) ; - return 1; - } - - /* Open temporary file for output */ - sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd=mkstemp(name))==-1) { - fprintf(stderr,"cannot create temporary file: exiting plot") ; - return 1; - } - /* Store file name in array for future deletion */ - strcpy(handle->to_delete[handle->ntmp], name) ; - handle->ntmp ++ ; - - /* Write data to this file */ - for (i=0 ; inplots > 0) return 1; + + /* Open one more temporary file? */ + if (handle->ntmp == GP_MAX_TMP_FILES - 1) { + fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); + return 1; + } + + /* Open temporary file for output */ + sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); + if ((tmpfd = mkstemp(name)) == -1) { + fprintf(stderr, "Cannot create temporary file: exiting plot"); + return 1; + } + + /* Store file name in array for future deletion */ + strcpy(handle->to_delete[handle->ntmp], name); + handle->ntmp++; + + /* Write data to this file */ + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + sprintf(cmd, "%d %d %g\n", i, j, points[i * cols + j]); + write(tmpfd, cmd, strlen(cmd)); } - close(tmpfd) ; - - /* Command to be sent to gnuplot */ - strcpy(cmd, "splot") ; - - if (title == NULL) { - sprintf(line, "%s \"%s\" with %s", cmd, name, handle->pstyle) ; - } else { - sprintf(line, "%s \"%s\" title \"%s\" with %s", cmd, name, - title, handle->pstyle) ; - } - - /* send command to gnuplot */ - gnuplot_cmd(handle, line) ; - handle->nplots++ ; - return 0; + strcpy(cmd, "\n"); + write(tmpfd, cmd, strlen(cmd)); + } + close(tmpfd); + + /* Command to be sent to gnuplot */ + if (title == NULL) { + sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); + } else { + sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); + } + + /* send command to gnuplot */ + gnuplot_cmd(handle, cmd); + handle->nplots++; + return 0; } /*-------------------------------------------------------------------------*/ /** - @brief Plot contours from a list of points. - @param handle Gnuplot session control handle. - @param x Pointer to a list of x coordinates. (length=nx*ny) - @param y Pointer to a list of y coordinates. (length=nx*ny) - @param z Pointer to a list of z coordinates. (length=nx*ny) - @param nx Number of doubles in x-direction - @param ny Number of doubles in y-direction - @param title Title of the plot. - @return void - - gnuplot_contour_plot(handle,x,y,z,n,title); + @brief Plot contours from a list of points. + @param handle Gnuplot session control handle. + @param x Pointer to a list of x coordinates. (length = nx*ny) + @param y Pointer to a list of y coordinates. (length = nx*ny) + @param z Pointer to a list of z coordinates. (length = nx*ny) + @param nx Number of doubles in x-direction + @param ny Number of doubles in y-direction + @param title Title of the plot. + @return int 1 if error encountered, 0 otherwise + + gnuplot_contour_plot(handle, x, y, z, n, title); Based on gnuplot_splot, modifications by Robert Bradley 23/11/2005 - Plots a contour plot from a list of points, passed in the form of three arrays x, y and z. - + Plots a contour plot from a list of points, passed as arrays x, y and z. + @code - gnuplot_ctrl *h ; - double x[50] ; y[50] ; z[50]; - int i ; - - h = gnuplot_init() ; - int count=100; - double x[count*count],y[count*count],z[count*count]; - int i,j; - for (i=0;inplots > 0) - return 1; - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, - "maximum # of temporary files reached (%d): cannot open more", - GP_MAX_TMP_FILES) ; - return 1; - } - - /* Open temporary file for output */ - sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd=mkstemp(name))==-1) { - fprintf(stderr,"cannot create temporary file: exiting plot") ; - return 1; - } - /* Store file name in array for future deletion */ - strcpy(handle->to_delete[handle->ntmp], name) ; - handle->ntmp ++ ; - - /* Write data to this file */ - - for (i=0 ; inplots > 0) return 1; + + /* Open one more temporary file? */ + if (handle->ntmp == GP_MAX_TMP_FILES - 1) { + fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); + return 1; + } + + /* Open temporary file for output */ + sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); + if ((tmpfd = mkstemp(name)) == -1) { + fprintf(stderr, "Cannot create temporary file: exiting plot"); + return 1; + } + + /* Store file name in array for future deletion */ + strcpy(handle->to_delete[handle->ntmp], name); + handle->ntmp++; + + /* Write data to this file */ + for (int i = 0; i < nx; i++) { + for (int j = 0; j < ny; j++) { + sprintf(cmd, "%g %g %g\n", x[nx * i + j], y[nx * i + j], z[nx * i + j]); + write(tmpfd, cmd, strlen(cmd)); } - close(tmpfd) ; - - /* Command to be sent to gnuplot */ - gnuplot_cmd(handle,"unset surface"); - gnuplot_cmd(handle,"set contour base"); - gnuplot_cmd(handle,"set view map"); - gnuplot_cmd(handle,"set view 0,0"); - strcpy(cmd, "splot") ; - - if (title == NULL) { - sprintf(line, "%s \"%s\" with %s", cmd, name, handle->pstyle) ; - } else { - sprintf(line, "%s \"%s\" title \"%s\" with %s", cmd, name, - title, handle->pstyle) ; - } - - /* send command to gnuplot */ - gnuplot_cmd(handle, line) ; - handle->nplots++ ; - return 0; + sprintf(cmd, "\n"); + write(tmpfd, cmd, strlen(cmd)); + } + close(tmpfd); + + /* Command to be sent to gnuplot */ + gnuplot_cmd(handle, "unset surface"); + gnuplot_cmd(handle, "set contour base"); + gnuplot_cmd(handle, "set view map"); + gnuplot_cmd(handle, "set view 0,0"); + + if (title == NULL) { + sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); + } else { + sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); + } + + /* send command to gnuplot */ + gnuplot_cmd(handle, cmd); + handle->nplots++; + return 0; } /*-------------------------------------------------------------------------*/ /** - @brief Plot a 3d graph using callback functions to return the points - @param handle Gnuplot session control handle. - @param obj Pointer to an arbitrary object. - @param getPoint Pointer to a callback function. - @param n Number of doubles in x (y and z must be the the same). - @param title Title of the plot. - @return void - -Calback: - -void getPoint(void *object,gnuplot_point *point,int index,int pointCount); - @param obj Pointer to an arbitrary object - @param point Pointer to the returned point struct (double x,y,z) - @param i Index of the current point (0 to n-1) - @param n Number of points - @return void + @brief Plot a 3d graph using callback functions to return the points + @param handle Gnuplot session control handle. + @param obj Pointer to an arbitrary object. + @param getPoint Pointer to a callback function. + @param n Number of doubles in x (y and z must be the the same). + @param title Title of the plot. + @return int 1 if error encountered, 0 otherwise + + Calback: + + void getPoint(void *object, gnuplot_point *point, int index, int pointCount); + @param obj Pointer to an arbitrary object + @param point Pointer to the returned point struct (double x, y, z) + @param i Index of the current point (0 to n-1) + @param n Number of points + @return void */ /*--------------------------------------------------------------------------*/ -int gnuplot_splot_obj(gnuplot_ctrl *handle, - void *obj, - void (*getPoint)(void*,gnuplot_point*,int,int), - int n, - char *title) { - int i; - int tmpfd ; - char name[128] ; - char cmd[GP_CMD_SIZE] ; - char line[GP_CMD_SIZE] ; - - if (handle==NULL || getPoint==NULL || (n<1)) return 1; - if (handle->nplots > 0) - return 1; - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, - "maximum # of temporary files reached (%d): cannot open more", - GP_MAX_TMP_FILES) ; - return 1; - } - - /* Open temporary file for output */ - sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd=mkstemp(name))==-1) { - fprintf(stderr,"cannot create temporary file: exiting plot") ; - return 1; - } - /* Store file name in array for future deletion */ - strcpy(handle->to_delete[handle->ntmp], name) ; - handle->ntmp ++ ; - - /* Write data to this file */ - gnuplot_point point; - for (i=0;ipstyle) ; - } else { - sprintf(line, "%s \"%s\" title \"%s\" with %s", cmd, name, - title, handle->pstyle) ; - } - - /* send command to gnuplot */ - gnuplot_cmd(handle, line) ; - handle->nplots++ ; - return 0; -} - -/* - @brief Plot a 2d graph using a callback function to return points. - @param handle Gnuplot session control handle. - @param obj Pointer to an arbitrary object. - @param getPoint Pointer to a callback function. - @param n Number of points. - @param title Title of the plot. - @return void - -The callback function is of the following form, and is called once for each -point plotted: - -void getPoint(void *object,gnuplot_point *point,int index,int pointCount); - @param obj Pointer to an arbitrary object - @param point Pointer to the returned point struct (double x,y,z) - @param i Index of the current point (0 to n-1) - @param n Number of points - @return void - -For example (where points is an array of points in this case): - -void PlotPoint(void *obj,gnuplot_point *point,int i, int n) { - Point *p=(Point*) obj; - point->x=p[i].x; - point->y=p[i].y; +int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title) { + int tmpfd; + char name[128]; + char cmd[GP_CMD_SIZE]; + + if (handle == NULL || getPoint == NULL || (n < 1)) return 1; + if (handle->nplots > 0) return 1; + + /* Open one more temporary file? */ + if (handle->ntmp == GP_MAX_TMP_FILES - 1) { + fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); + return 1; + } + + /* Open temporary file for output */ + sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); + if ((tmpfd = mkstemp(name)) == -1) { + fprintf(stderr, "Cannot create temporary file: exiting plot"); + return 1; + } + + /* Store file name in array for future deletion */ + strcpy(handle->to_delete[handle->ntmp], name); + handle->ntmp++; + + /* Write data to this file */ + gnuplot_point point; + for (int i = 0; i < n; i++) { + getPoint(obj, &point, i, n); + sprintf(cmd, "%g %g %g\n", point.x, point.y, point.z); + write(tmpfd, cmd, strlen(cmd)); + } + close(tmpfd); + + /* Command to be sent to gnuplot */ + if (title == NULL) { + sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); + } else { + sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); + } + + /* send command to gnuplot */ + gnuplot_cmd(handle, cmd); + handle->nplots++; + return 0; } -int main(int argc, char *argv[]) { -... -gnuplot_plot_obj_xy(gp,points,PlotPoint,pCount,"Points"); -... -} - -Alternately, PlotPoint could return values based on a complex formula and many -sources of information. For example, it could be used to perform a Discrete -Fourier Transform on an array of complex numbers, calculating one transformed -point per call. - -Note: you should always explicitly set all the relevant parts of the struct. -However, you may ignore the z component for 2D plots. -*/ - -int gnuplot_plot_obj_xy( - gnuplot_ctrl *handle, - void *obj, - void (*getPoint)(void*,gnuplot_point*,int,int), - int n, - char *title -) -{ - int i ; - int tmpfd ; - char name[128] ; - char cmd[GP_CMD_SIZE] ; - char line[GP_CMD_SIZE] ; - - if (handle==NULL || getPoint==NULL || (n<1)) return 1; - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, - "maximum # of temporary files reached (%d): cannot open more", - GP_MAX_TMP_FILES) ; - return 1; - } - - /* Open temporary file for output */ - sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd=mkstemp(name))==-1) { - fprintf(stderr,"cannot create temporary file: exiting plot") ; - return 1; - } - /* Store file name in array for future deletion */ - strcpy(handle->to_delete[handle->ntmp], name) ; - handle->ntmp ++ ; - - /* Write data to this file */ - gnuplot_point point; - for (i=0 ; inplots > 0) { - strcpy(cmd, "replot") ; - } else { - strcpy(cmd, "plot") ; - } - - if (title == NULL) { - sprintf(line, "%s \"%s\" with %s", cmd, name, handle->pstyle) ; - } else { - sprintf(line, "%s \"%s\" title \"%s\" with %s", cmd, name, - title, handle->pstyle) ; - } +/*-------------------------------------------------------------------------*/ +/** + @brief Plot a 2d graph using a callback function to return points. + @param handle Gnuplot session control handle. + @param obj Pointer to an arbitrary object. + @param getPoint Pointer to a callback function. + @param n Number of points. + @param title Title of the plot. + @return int 1 if error encountered, 0 otherwise + + The callback function is of the following form, and is called once for each + point plotted: + + void getPoint(void *object,gnuplot_point *point,int index,int pointCount); + @param obj Pointer to an arbitrary object + @param point Pointer to the returned point struct (double x,y,z) + @param i Index of the current point (0 to n-1) + @param n Number of points + @return void + + For example (where points is an array of points in this case): + + void PlotPoint(void *obj, gnuplot_point *point, int i, int n) { + Point *p = (Point*) obj; + point->x = p[i].x; + point->y = p[i].y; + } + + int main(int argc, char *argv[]) { + ... + gnuplot_plot_obj_xy(gp, points, PlotPoint, pCount, "Points"); + ... + } + + Alternately, PlotPoint could return values based on a complex formula and many + sources of information. For example, it could be used to perform a Discrete + Fourier Transform on an array of complex numbers, calculating one transformed + point per call. + + Note: always explicitly set all relevant parts of the struct. + However, the z component for 2D plots can be ignored. + */ +/*-------------------------------------------------------------------------*/ - /* send command to gnuplot */ - gnuplot_cmd(handle, line) ; - handle->nplots++ ; - return 0; +int gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title) { + int tmpfd; + char name[128]; + char cmd[GP_CMD_SIZE]; + + if (handle == NULL || getPoint == NULL || (n < 1)) return 1; + + /* Open one more temporary file? */ + if (handle->ntmp == GP_MAX_TMP_FILES - 1) { + fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); + return 1; + } + + /* Open temporary file for output */ + sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); + if ((tmpfd = mkstemp(name)) == -1) { + fprintf(stderr, "Cannot create temporary file: exiting plot"); + return 1; + } + + /* Store file name in array for future deletion */ + strcpy(handle->to_delete[handle->ntmp], name); + handle->ntmp++; + + /* Write data to this file */ + gnuplot_point point; + for (int i = 0; i < n; i++) { + getPoint(obj, &point, i, n); + sprintf(cmd, "%g %g\n", point.x, point.y); + write(tmpfd, cmd, strlen(cmd)); + } + close(tmpfd); + + /* Command to be sent to gnuplot */ + if (title == NULL) { + sprintf(cmd, "%s \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, handle->pstyle); + } else { + sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, title, handle->pstyle); + } + + /* Send command to gnuplot */ + gnuplot_cmd(handle, cmd); + handle->nplots++; + return 0; } /*-------------------------------------------------------------------------*/ /** - @brief Open a new session, plot a signal, close the session. - @param title Plot title - @param style Plot style - @param label_x Label for X - @param label_y Label for Y - @param x Array of X coordinates - @param y Array of Y coordinates (can be NULL) - @param n Number of values in x and y. - @return + @brief Open a new session, plot a signal, close the session. + @param title Plot title + @param style Plot style + @param label_x Label for X + @param label_y Label for Y + @param x Array of X coordinates + @param y Array of Y coordinates (can be NULL) + @param n Number of values in x and y. + @return void This function opens a new gnuplot session, plots the provided signal as an X or XY signal depending on a provided y, waits for a carriage return on stdin and closes the session. - It is Ok to provide an empty title, empty style, or empty labels for - X and Y. Defaults are provided in this case. + An empty title, empty style, or empty labels for X and Y may be provided. + Defaults are provided in this case. */ /*--------------------------------------------------------------------------*/ -void gnuplot_plot_once( - char * title, - char * style, - char * label_x, - char * label_y, - double * x, - double * y, - int n -) -{ - gnuplot_ctrl * handle ; - - if (x==NULL || n<1) return ; - - if ((handle = gnuplot_init()) == NULL) return ; - if (style!=NULL) { - gnuplot_setstyle(handle, style); - } else { - gnuplot_setstyle(handle, "lines"); - } - if (label_x!=NULL) { - gnuplot_set_xlabel(handle, label_x); - } else { - gnuplot_set_xlabel(handle, "X"); - } - if (label_y!=NULL) { - gnuplot_set_ylabel(handle, label_y); - } else { - gnuplot_set_ylabel(handle, "Y"); - } - if (y==NULL) { - gnuplot_plot_x(handle, x, n, title); - } else { - gnuplot_plot_xy(handle, x, y, n, title); - } - printf("press ENTER to continue\n"); - while (getchar()!='\n') {} - gnuplot_close(handle); - return ; +void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, double *x, double *y, int n) { + gnuplot_ctrl *handle; // why is this a local variable? + + if (x == NULL || n < 1) return; + if ((handle = gnuplot_init()) == NULL) return; + gnuplot_setstyle(handle, (style == NULL) ? "lines" : style); + gnuplot_set_axislabel(handle, (label_x == NULL) ? 'X' : label_x, 'x'); + gnuplot_set_axislabel(handle, (label_y == NULL) ? 'Y' : label_y, 'y'); + if (y == NULL) { + gnuplot_plot_x(handle, x, n, title); + } else { + gnuplot_plot_xy(handle, x, y, n, title); + } + printf("Press Enter to continue\n"); + while (getchar() != '\n') {} + gnuplot_close(handle); + return; } - - - /*-------------------------------------------------------------------------*/ /** - @brief Plot a slope on a gnuplot session. - @param handle Gnuplot session control handle. - @param a Slope. - @param b Intercept. - @param title Title of the plot. - @return void + @brief Plot a slope (linear equation) on a gnuplot session. + @param handle Gnuplot session control handle. + @param a Slope. + @param b Intercept. + @param title Title of the plot. + @return void @doc - Plot a slope on a gnuplot session. The provided slope has an - equation of the form y=ax+b + Plot a slope on a gnuplot session. The provided equation has the form y=ax+b Example: @code - gnuplot_ctrl * h ; - double a, b ; + gnuplot_ctrl *h; + double a, b; - h = gnuplot_init() ; - gnuplot_plot_slope(h, 1.0, 0.0, "unity slope") ; - sleep(2) ; - gnuplot_close(h) ; + h = gnuplot_init(); + gnuplot_plot_slope(h, 1.0, 0.0, "unity slope"); + sleep(2); + gnuplot_close(h); @endcode */ /*--------------------------------------------------------------------------*/ - - -void gnuplot_plot_slope( - gnuplot_ctrl * handle, - double a, - double b, - char * title -) -{ - char stitle[GP_TITLE_SIZE] ; - char cmd[GP_CMD_SIZE] ; - - if (title == NULL) { - strcpy(stitle, "no title") ; - } else { - strcpy(stitle, title) ; - } - if (handle->nplots > 0) { - sprintf(cmd, "replot %g * x + %g title \"%s\" with %s", - a, b, title, handle->pstyle) ; - } else { - sprintf(cmd, "plot %g * x + %g title \"%s\" with %s", - a, b, title, handle->pstyle) ; - } - gnuplot_cmd(handle, cmd) ; - handle->nplots++ ; - return ; -} +void gnuplot_plot_slope (gnuplot_ctrl *handle, double a, double b, char *title) { + char cmd[GP_CMD_SIZE]; + char title_str[GP_TITLE_SIZE]; + strcpy(title_str, (title == NULL) ? "no title" : title); + sprintf(cmd, "%s %g * x + %g title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", a, b, title, handle->pstyle); + gnuplot_cmd(handle, cmd); + handle->nplots++; + return; +} /*-------------------------------------------------------------------------*/ /** - @brief Plot a curve of given equation y=f(x). - @param h Gnuplot session control handle. - @param equation Equation to plot. - @param title Title of the plot. - @return void + @brief Plot a curve of given equation y=f(x). + @param handle Gnuplot session control handle. + @param equation Equation to plot. + @param title Title of the plot. + @return void Plots out a curve of given equation. The general form of the - equation is y=f(x), you only provide the f(x) side of the equation. + equation is y=f(x), by providing the f(x) side of the equation only. Example: @code - gnuplot_ctrl *h ; - char eq[80] ; + gnuplot_ctrl *h; + char eq[80]; - h = gnuplot_init() ; - strcpy(eq, "sin(x) * cos(2*x)") ; - gnuplot_plot_equation(h, eq, "sine wave", normal) ; - gnuplot_close(h) ; + h = gnuplot_init(); + strcpy(eq, "sin(x) * cos(2*x)"); + gnuplot_plot_equation(h, eq, "sine wave", normal); + gnuplot_close(h); @endcode */ /*--------------------------------------------------------------------------*/ -void gnuplot_plot_equation( - gnuplot_ctrl * h, - char * equation, - char * title -) -{ - char cmd[GP_CMD_SIZE]; - char plot_str[GP_EQ_SIZE] ; - char title_str[GP_TITLE_SIZE] ; - - if (title == NULL) { - strcpy(title_str, "no title") ; - } else { - strcpy(title_str, title) ; - } - if (h->nplots > 0) { - strcpy(plot_str, "replot") ; - } else { - strcpy(plot_str, "plot") ; - } - - sprintf(cmd, "%s %s title \"%s\" with %s", - plot_str, equation, title_str, h->pstyle) ; - gnuplot_cmd(h, cmd) ; - h->nplots++ ; - return ; +void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title) { + char cmd[GP_CMD_SIZE]; + char plot_str[GP_EQ_SIZE]; + char title_str[GP_TITLE_SIZE]; + + strcpy(title_str, (title == NULL) ? "no title" : title); + strcpy(plot_str, (handle->nplots > 0) ? "replot" : "plot"); + sprintf(cmd, "%s %s title \"%s\" with %s", plot_str, equation, title_str, handle->pstyle); + gnuplot_cmd(handle, cmd); + handle->nplots++; + return; } /*-------------------------------------------------------------------------*/ /** - @brief Save a graph as a postscript file on the hard disk - @param h Gnuplot session control handle. - @param equation Equation to plot. - @param title Title of the plot. + @brief Save a graph as a Postscript file on storage + @param handle Gnuplot session control handle. + @param filename Filename to write to. + @param color @return void - A wrapper for the gnuplot_cmd function that sets the terminal - the terminal to postscript, replots the raph and then resets - the terminal to x11. + A wrapper for the gnuplot_cmd function that sets the terminal to Postscript, + replots the graph and then resets the terminal to x11. Example: @code - gnuplot_ctrl *h ; - char eq[80] ; - - h = gnuplot_init() ; - strcpy(eq, "sin(x) * cos(2*x)") ; - gnuplot_plot_equation(h, eq, "sine wave", normal) ; - gnuplot_hardcopy(h, "sinewave.ps"); - gnuplot_close(h) ; + gnuplot_ctrl *h; + char eq[80]; + + h = gnuplot_init(); + strcpy(eq, "sin(x) * cos(2*x)"); + gnuplot_plot_equation(h, eq, "sine wave", normal); + gnuplot_hardcopy(h, "sinewave.ps"); + gnuplot_close(h); @endcode */ /*--------------------------------------------------------------------------*/ -void gnuplot_hardcopy( - gnuplot_ctrl * h, - char * filename -) -{ - gnuplot_cmd(h, "set terminal postscript"); - - gnuplot_cmd(h, "set output \"%s\"", filename); - gnuplot_cmd(h, "replot"); - - gnuplot_cmd(h, "set terminal %s",h->term); -} - -/*-------------------------------------------------------------------------*/ -/** - @brief Save a graph in colour as a postscript file on the hard disk - @param h Gnuplot session control handle. - @param equation Equation to plot. - @param title Title of the plot. - @return void - - Added by Robert Bradley on 12th october 2004 - - This function is identical in syntax (and implementation) to gnuplot_hardcopy, but the resulting - PostScript file retains colour information. - - */ -/*--------------------------------------------------------------------------*/ - -void gnuplot_hardcopy_colour( - gnuplot_ctrl * h, - char * filename -) -{ - gnuplot_cmd(h, "set terminal postscript enhanced color"); - - gnuplot_cmd(h, "set output \"%s\"", filename); - gnuplot_cmd(h, "replot"); - gnuplot_cmd(h, "set terminal %s",h->term); +void gnuplot_hardcopy (gnuplot_ctrl *handle, char *filename, char *color) { + if (color == NULL) { + gnuplot_cmd(handle, "set terminal postscript"); + } else { + gnuplot_cmd(handle, "set terminal postscript enhanced color"); + } + gnuplot_cmd(handle, "set output \"%s\"", filename); + gnuplot_cmd(handle, "replot"); + gnuplot_cmd(handle, "set terminal %s", handle->term); } #endif From 5298f6555bb0a7c5c9bc78aae0bd277b181b251e Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Mon, 29 May 2023 09:07:04 +0200 Subject: [PATCH 006/128] Update gnuplot_i_example.c Cosmetic changes --- gnuplot_i_example.c | 263 +++++++++++++++++++------------------------- 1 file changed, 115 insertions(+), 148 deletions(-) diff --git a/gnuplot_i_example.c b/gnuplot_i_example.c index cb5ce81..7cfe9a4 100755 --- a/gnuplot_i_example.c +++ b/gnuplot_i_example.c @@ -1,157 +1,124 @@ - /* * Examples of gnuplot_i.c usage */ #include #include - #include "gnuplot_i.h" -#define SLEEP_LGTH 2 -#define NPOINTS 50 - -int main(int argc, char *argv[]) -{ - gnuplot_ctrl * h1, - * h2, - * h3, - * h4 ; - double x[NPOINTS] ; - double y[NPOINTS] ; - int i ; - - /* - * Initialize the gnuplot handle - */ - printf("*** example of gnuplot control through C ***\n") ; - h1 = gnuplot_init() ; - - /* - * Slopes - */ - gnuplot_setstyle(h1, "lines") ; - - printf("*** plotting slopes\n") ; - printf("y = x\n") ; - gnuplot_plot_slope(h1, 1.0, 0.0, "unity slope") ; - sleep(SLEEP_LGTH) ; - - printf("y = 2*x\n") ; - gnuplot_plot_slope(h1, 2.0, 0.0, "y=2x") ; - sleep(SLEEP_LGTH) ; - - printf("y = -x\n") ; - gnuplot_plot_slope(h1, -1.0, 0.0, "y=-x") ; - sleep(SLEEP_LGTH) ; - - - /* - * Equations - */ - - gnuplot_resetplot(h1) ; - printf("\n\n") ; - printf("*** various equations\n") ; - printf("y = sin(x)\n") ; - gnuplot_plot_equation(h1, "sin(x)", "sine") ; - sleep(SLEEP_LGTH) ; - - printf("y = log(x)\n") ; - gnuplot_plot_equation(h1, "log(x)", "logarithm") ; - sleep(SLEEP_LGTH) ; - - printf("y = sin(x)*cos(2*x)\n") ; - gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product") ; - sleep(SLEEP_LGTH) ; - - - /* - * Styles - */ - - gnuplot_resetplot(h1) ; - printf("\n\n") ; - printf("*** showing styles\n") ; - - printf("sine in points\n") ; - gnuplot_setstyle(h1, "points") ; - gnuplot_plot_equation(h1, "sin(x)", "sine") ; - sleep(SLEEP_LGTH) ; - - printf("sine in impulses\n") ; - gnuplot_setstyle(h1, "impulses") ; - gnuplot_plot_equation(h1, "sin(x)", "sine") ; - sleep(SLEEP_LGTH) ; - - printf("sine in steps\n") ; - gnuplot_setstyle(h1, "steps") ; - gnuplot_plot_equation(h1, "sin(x)", "sine") ; - sleep(SLEEP_LGTH) ; - - /* - * User defined 1d and 2d point sets - */ - - gnuplot_resetplot(h1) ; - gnuplot_setstyle(h1, "impulses") ; - printf("\n\n") ; - printf("*** user-defined lists of doubles\n") ; - for (i=0 ; i Date: Mon, 29 May 2023 22:04:34 +0200 Subject: [PATCH 007/128] Update gnuplot_i.c * Code comment updates * Doxygen friendly --- gnuplot_i.c | 379 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 219 insertions(+), 160 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index 426bd3c..38a06c8 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -9,28 +9,9 @@ @version $Revision: 2.10.3 $ @brief C interface to gnuplot. - gnuplot is an open-source, command-driven graphical display tool for Unix. - It compiles and works quite well on a number of Unix flavours as well as - other operating systems. The following module enables sending display - requests to gnuplot through C calls. - - 3D and color printing extensions added Oct 2004 by Robert Bradley - (robert.bradley@merton.ox.ac.uk), based on existing code: - - gnuplot_splot (plot a 3D graph) - gnuplot_hardcopy (for printing in color) - - OS X and limited Windows support added 11-13 Sep 2005: - - On Windows, pgnuplot and wgnuplot.exe must be in the current directory. - - On OS X, if DISPLAY environment variable is not set, or USE_AQUA=1, aqua is - used instead of x11. - - gnuplot_setterm added to allow the terminal type to be set. - - gnuplot_plot_obj_xy added 15 Sep 2005 (plots data from arbitrary - structures using callback functions) - gnuplot_contour_plot added 23 Nov 2005 (plots contours, use - gnuplot_setstyle to set the contour style) - gnuplot_splot_grid added 2 Apr 2006 (plots 2D grids of data [x,y]) + gnuplot_i is a C interface library that enables sending display + requests to gnuplot through C calls. gnuplot itself is an open source + plotting library also written in C. */ /*--------------------------------------------------------------------------*/ @@ -42,21 +23,21 @@ */ /*--------------------------------------------------------------------------- - Includes + Includes ---------------------------------------------------------------------------*/ #include "gnuplot_i.h" /*--------------------------------------------------------------------------- - Defines + Defines ---------------------------------------------------------------------------*/ /** Maximal size of a gnuplot command */ -#define GP_CMD_SIZE 2048 +#define GP_CMD_SIZE 2048 /** Maximal size of a plot title */ -#define GP_TITLE_SIZE 80 +#define GP_TITLE_SIZE 80 /** Maximal size for an equation */ -#define GP_EQ_SIZE 512 +#define GP_EQ_SIZE 512 /** Maximal size of a name in the PATH */ #define PATH_MAXNAMESZ 4096 @@ -76,7 +57,7 @@ #endif /*--------------------------------------------------------------------------- - Function codes + Function codes ---------------------------------------------------------------------------*/ #ifdef _WIN32 @@ -102,12 +83,12 @@ int mkstemp (char *templ) { /*-------------------------------------------------------------------------*/ /** - @brief Find out where a command lives in your PATH. + @brief Find out where a command lives in the PATH. @param pname Name of the program to look for. @return pointer to statically allocated character string. This is the C equivalent to the 'which' command in Unix. It parses - your PATH environment variable to find out where a command lives. + the PATH environment variable to find out where a command lives. The returned character string is statically allocated within this function, i.e. there is no need to free it. Note that the contents of this string will change from one call to the next, @@ -117,14 +98,14 @@ int mkstemp (char *templ) { prefixing path of any kind, i.e. only the command name. The returned string is the path in which a command matching the same name was found. - Examples (assuming there is a prog named 'hello' in the cwd): + Examples: - @verbatim - gnuplot_get_program_path("hello") returns "." - gnuplot_get_program_path("ls") returns "/bin" - gnuplot_get_program_path("csh") returns "/usr/bin" - gnuplot_get_program_path("/bin/ls") returns NULL - @endverbatim + @code + gnuplot_get_program_path("hello") returns "." + gnuplot_get_program_path("ls") returns "/bin" + gnuplot_get_program_path("csh") returns "/usr/bin" + gnuplot_get_program_path("/bin/ls") returns NULL + @endcode */ /*-------------------------------------------------------------------------*/ @@ -141,7 +122,7 @@ char *gnuplot_get_program_path (char *pname) { return buf; } - /* Try out in all paths given in the PATH variable */ + /* Try in all paths given in the PATH variable */ buf[0] = 0; path = getenv("PATH"); if (path != NULL) { @@ -176,11 +157,11 @@ char *gnuplot_get_program_path (char *pname) { /*-------------------------------------------------------------------------*/ /** - @brief Opens up a gnuplot session, ready to receive commands. + @brief Opens a gnuplot session, ready to receive commands. @return Newly allocated gnuplot control structure. - This opens up a new gnuplot session, ready for input. The struct - controlling a gnuplot session should remain opaque and only be + This opens a new gnuplot session, ready for input. + The struct controlling a gnuplot session should remain opaque and only be accessed through the provided functions. The session must be closed using gnuplot_close(). @@ -238,10 +219,10 @@ gnuplot_ctrl *gnuplot_init (void) { @param handle Gnuplot session control handle. @return void - Kills the child PID and deletes all opened temporary files. + Kills the child process-ID (PID) and deletes all opened temporary files. It is mandatory to call this function to close the handle, otherwise - temporary files are not cleaned and child process might survive. - + temporary files are not cleaned from memory and the child process might + survive and unable to be reused. */ /*--------------------------------------------------------------------------*/ @@ -268,8 +249,8 @@ void gnuplot_close (gnuplot_ctrl *handle) { /*-------------------------------------------------------------------------*/ /** @brief Sends a command to an active gnuplot session. - @param handle Gnuplot session control handle - @param cmd Command to send, same as a printf statement. + @param handle Gnuplot session control handle + @param cmd Command to send, same as a printf statement. This sends a string to an active gnuplot session, to be executed. There is no way to know if the command has been successfully executed or not. @@ -278,8 +259,8 @@ void gnuplot_close (gnuplot_ctrl *handle) { Examples: @code - gnuplot_cmd(g, "plot %d*x", 23.0); - gnuplot_cmd(g, "plot %g * cos(%g * x)", 32.0, -3.0); + gnuplot_cmd(h, "plot %d*x", 23.0); + gnuplot_cmd(h, "plot %g * cos(%g * x)", 32.0, -3.0); @endcode Since the communication to the gnuplot process is run through a standard Unix @@ -405,26 +386,25 @@ void gnuplot_resetplot (gnuplot_ctrl *handle) { /** @brief Plots a 2d graph from a list of doubles. @param handle Gnuplot session control handle. - @param d Array of doubles. + @param x Array of doubles. @param n Number of values in the passed array. - @param title Title of the plot. + @param title Title of the plot (can be NULL). @return void - Plots out a 2d graph from a list of doubles. The x-coordinate is the - index of the double in the list, the y coordinate is the double in - the list. + Plots a 2d graph from a list of doubles. The x-coordinate is the index of the + double in the list, the y coordinate is the double in the list. Example: @code gnuplot_ctrl *h; - double d[50]; + double x[50]; h = gnuplot_init(); for (int i = 0; i < 50; i++) { - d[i] = (double)(i*i); + x[i] = (double)(i*i); } - gnuplot_plot_x(h, d, 50, "parabola"); + gnuplot_plot_x(h, x, 50, "parabola"); sleep(2); gnuplot_close(h); @endcode @@ -436,7 +416,17 @@ void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title) { char name[128]; char cmd[GP_CMD_SIZE]; - if (handle == NULL || x == NULL || (n < 1)) return; + /* Trap errors on mandatory arguments */ + if (handle == NULL || x == NULL || (n < 1)) { + fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); + return; + } + + /* Do not open a new gnuplot session if one is already open */ + if (handle->nplots > 0) { + fprintf(stderr, "A gnuplot session is already open and held by aother process"); + return; + } /* Open one more temporary file? */ if (handle->ntmp == GP_MAX_TMP_FILES - 1) { @@ -444,7 +434,7 @@ void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title) { return; } - /* Open temporary file for output */ + /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); if ((tmpfd = mkstemp(name)) == -1) { fprintf(stderr, "Cannot create temporary file: exiting plot"); @@ -455,21 +445,21 @@ void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title) { strcpy(handle->to_delete[handle->ntmp], name); handle->ntmp++; - /* Write data to this file */ + /* Write data to this file */ for (int i = 0; i < n; i++) { sprintf(cmd, "%g\n", x[i]); write(tmpfd, cmd, strlen(cmd)); } close(tmpfd); - /* Command to be sent to gnuplot */ + /* Command to be sent to gnuplot */ if (title == NULL) { sprintf(cmd, "%s \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, handle->pstyle); } else { sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, title, handle->pstyle); } - /* send command to gnuplot */ + /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; return; @@ -482,13 +472,15 @@ void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title) { @param x Pointer to a list of x coordinates. @param y Pointer to a list of y coordinates. @param n Number of doubles in x (assumed the same as in y). - @param title Title of the plot. + @param title Title of the plot (can be NULL). @return void Plots a 2d graph from a list of points. Provide points through a list of x and a list of y coordinates. Both arrays are assumed to contain the same number of values. + Example: + @code gnuplot_ctrl *h; double x[50], y[50]; @@ -510,7 +502,17 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t char name[128]; char cmd[GP_CMD_SIZE]; - if (handle == NULL || x == NULL || y == NULL || (n < 1)) return; + /* Trap errors on mandatory arguments */ + if (handle == NULL || x == NULL || y == NULL || (n < 1)) { + fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); + return; + } + + /* Do not open a new gnuplot session if one is already open */ + if (handle->nplots > 0) { + fprintf(stderr, "A gnuplot session is already open and held by aother process"); + return; + } /* Open one more temporary file? */ if (handle->ntmp == GP_MAX_TMP_FILES - 1) { @@ -518,7 +520,7 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t return; } - /* Open temporary file for output */ + /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); if ((tmpfd = mkstemp(name)) == -1) { fprintf(stderr, "Cannot create temporary file: exiting plot"); @@ -529,21 +531,21 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t strcpy(handle->to_delete[handle->ntmp], name); handle->ntmp++; - /* Write data to this file */ + /* Write data to this file */ for (int i = 0; i < n; i++) { sprintf(cmd, "%g %g\n", x[i], y[i]); write(tmpfd, cmd, strlen(cmd)); } close(tmpfd); - /* Command to be sent to gnuplot */ + /* Command to be sent to gnuplot */ if (title == NULL) { sprintf(cmd, "%s \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, handle->pstyle); } else { sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, title, handle->pstyle); } - /* send command to gnuplot */ + /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; return; @@ -556,16 +558,17 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t @param x Pointer to a list of x coordinates. @param y Pointer to a list of y coordinates. @param z Pointer to a list of z coordinates. - @param n Number of doubles in x (y and z must be the the same). - @param title Title of the plot. + @param n Number of doubles in x (same for y and z). + @param title Title of the plot (can be NULL). @return int 1 if error encountered, 0 otherwise - gnuplot_splot(handle,x,y,z,n,title); Based on gnuplot_plot_xy, modifications by Robert Bradley 12/10/2004 Plots a 3d graph from a list of points, passed as arrays x, y and z. All arrays are assumed to contain the same number of values. + Example: + @code gnuplot_ctrl *h; double x[50], y[50], z[50]; @@ -588,8 +591,17 @@ int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char name[128]; char cmd[GP_CMD_SIZE]; - if (handle == NULL || x == NULL || y == NULL || (n < 1)) return 1; - if (handle->nplots > 0) return 1; + /* Trap errors on mandatory arguments */ + if (handle == NULL || x == NULL || y == NULL || (n < 1)) { + fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); + return 1; + } + + /* Do not open a new gnuplot session if one is already open */ + if (handle->nplots > 0) { + fprintf(stderr, "A gnuplot session is already open and held by aother process"); + return 1; + } /* Open one more temporary file? */ if (handle->ntmp == GP_MAX_TMP_FILES - 1) { @@ -597,7 +609,7 @@ int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, return 1; } - /* Open temporary file for output */ + /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); if ((tmpfd = mkstemp(name)) == -1) { fprintf(stderr, "Cannot create temporary file: exiting plot"); @@ -608,21 +620,21 @@ int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, strcpy(handle->to_delete[handle->ntmp], name); handle->ntmp++; - /* Write data to this file */ + /* Write data to this file */ for (int i = 0; i < n; i++) { sprintf(cmd, "%g %g %g\n", x[i], y[i], z[i]); write(tmpfd, cmd, strlen(cmd)); } close(tmpfd); - /* Command to be sent to gnuplot */ + /* Command to be sent to gnuplot */ if (title == NULL) { sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); } else { sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); } - /* send command to gnuplot */ + /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; return 0; @@ -635,11 +647,16 @@ int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, @param points Pointer to a grid of points (rows,cols). @param rows Number of rows (y points). @param cols Number of columns (x points). - @param title Title of the plot. + @param title Title of the plot (can be NULL). @return int 1 if error encountered, 0 otherwise - gnuplot_splot_grid(handle,(double*) points,rows,cols,title); - Based on gnuplot_splot, modifications by Robert Bradley 2/4/2006 + Example: + + @code + gnuplot_splot_grid(handle, (double*) points, rows, cols, title); + @endcode + + Based on `gnuplot_splot`, modifications by Robert Bradley 2/4/2006 Plots a 3d graph from a grid of points, passed in the form of an array [x,y]. */ @@ -650,11 +667,17 @@ int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols char name[128]; char cmd[GP_CMD_SIZE]; + /* Trap errors on mandatory arguments */ if (handle == NULL || points == NULL || (rows < 1) || (cols < 1)) { - fprintf(stderr, "One of the parameters to gnuplot_splot_grid has been misspecified"); + fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); + return 1; + } + + /* Do not open a new gnuplot session if one is already open */ + if (handle->nplots > 0) { + fprintf(stderr, "A gnuplot session is already open and held by aother process"); return 1; } - if (handle->nplots > 0) return 1; /* Open one more temporary file? */ if (handle->ntmp == GP_MAX_TMP_FILES - 1) { @@ -662,7 +685,7 @@ int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols return 1; } - /* Open temporary file for output */ + /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); if ((tmpfd = mkstemp(name)) == -1) { fprintf(stderr, "Cannot create temporary file: exiting plot"); @@ -673,7 +696,7 @@ int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols strcpy(handle->to_delete[handle->ntmp], name); handle->ntmp++; - /* Write data to this file */ + /* Write data to this file */ for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { sprintf(cmd, "%d %d %g\n", i, j, points[i * cols + j]); @@ -684,14 +707,14 @@ int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols } close(tmpfd); - /* Command to be sent to gnuplot */ + /* Command to be sent to gnuplot */ if (title == NULL) { sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); } else { sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); } - /* send command to gnuplot */ + /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; return 0; @@ -701,20 +724,21 @@ int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols /** @brief Plot contours from a list of points. @param handle Gnuplot session control handle. - @param x Pointer to a list of x coordinates. (length = nx*ny) - @param y Pointer to a list of y coordinates. (length = nx*ny) - @param z Pointer to a list of z coordinates. (length = nx*ny) - @param nx Number of doubles in x-direction - @param ny Number of doubles in y-direction - @param title Title of the plot. + @param x Pointer to a list of x coordinates (length = nx*ny). + @param y Pointer to a list of y coordinates (length = nx*ny). + @param z Pointer to a list of z coordinates (length = nx*ny). + @param nx Number of doubles in x-direction. + @param ny Number of doubles in y-direction. + @param title Title of the plot (can be NULL). @return int 1 if error encountered, 0 otherwise - gnuplot_contour_plot(handle, x, y, z, n, title); Based on gnuplot_splot, modifications by Robert Bradley 23/11/2005 Plots a contour plot from a list of points, passed as arrays x, y and z. - @code + Example: + + @code gnuplot_ctrl *h; double x[50], y[50], z[50]; @@ -741,11 +765,17 @@ int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, char name[128]; char cmd[GP_CMD_SIZE]; - if (handle == NULL || x == NULL || y == NULL || (nx < 1) || (ny < 1)) [ - fprintf(stderr, "One of the parameters to gnuplot_contour_plot has been misspecified"); + /* Trap errors on mandatory arguments */ + if (handle == NULL || x == NULL || y == NULL || (nx < 1) || (ny < 1)) { + fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); + return 1; + } + + /* Do not open a new gnuplot session if one is already open */ + if (handle->nplots > 0) { + fprintf(stderr, "A gnuplot session is already open and held by aother process"); return 1; } - if (handle->nplots > 0) return 1; /* Open one more temporary file? */ if (handle->ntmp == GP_MAX_TMP_FILES - 1) { @@ -753,7 +783,7 @@ int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, return 1; } - /* Open temporary file for output */ + /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); if ((tmpfd = mkstemp(name)) == -1) { fprintf(stderr, "Cannot create temporary file: exiting plot"); @@ -764,7 +794,7 @@ int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, strcpy(handle->to_delete[handle->ntmp], name); handle->ntmp++; - /* Write data to this file */ + /* Write data to this file */ for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { sprintf(cmd, "%g %g %g\n", x[nx * i + j], y[nx * i + j], z[nx * i + j]); @@ -775,7 +805,7 @@ int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, } close(tmpfd); - /* Command to be sent to gnuplot */ + /* Command to be sent to gnuplot */ gnuplot_cmd(handle, "unset surface"); gnuplot_cmd(handle, "set contour base"); gnuplot_cmd(handle, "set view map"); @@ -787,7 +817,7 @@ int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); } - /* send command to gnuplot */ + /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; return 0; @@ -800,7 +830,7 @@ int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, @param obj Pointer to an arbitrary object. @param getPoint Pointer to a callback function. @param n Number of doubles in x (y and z must be the the same). - @param title Title of the plot. + @param title Title of the plot (can be NULL). @return int 1 if error encountered, 0 otherwise Calback: @@ -819,8 +849,17 @@ int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, char name[128]; char cmd[GP_CMD_SIZE]; - if (handle == NULL || getPoint == NULL || (n < 1)) return 1; - if (handle->nplots > 0) return 1; + /* Trap errors on mandatory arguments */ + if (handle == NULL || getPoint == NULL || (n < 1)) { + fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); + return 1; + } + + /* Do not open a new gnuplot session if one is already open */ + if (handle->nplots > 0) { + fprintf(stderr, "A gnuplot session is already open and held by aother process"); + return 1; + } /* Open one more temporary file? */ if (handle->ntmp == GP_MAX_TMP_FILES - 1) { @@ -828,7 +867,7 @@ int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, return 1; } - /* Open temporary file for output */ + /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); if ((tmpfd = mkstemp(name)) == -1) { fprintf(stderr, "Cannot create temporary file: exiting plot"); @@ -839,7 +878,7 @@ int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, strcpy(handle->to_delete[handle->ntmp], name); handle->ntmp++; - /* Write data to this file */ + /* Write data to this file */ gnuplot_point point; for (int i = 0; i < n; i++) { getPoint(obj, &point, i, n); @@ -848,14 +887,14 @@ int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, } close(tmpfd); - /* Command to be sent to gnuplot */ + /* Command to be sent to gnuplot */ if (title == NULL) { sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); } else { sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); } - /* send command to gnuplot */ + /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; return 0; @@ -868,37 +907,41 @@ int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, @param obj Pointer to an arbitrary object. @param getPoint Pointer to a callback function. @param n Number of points. - @param title Title of the plot. + @param title Title of the plot (can be NULL). @return int 1 if error encountered, 0 otherwise The callback function is of the following form, and is called once for each point plotted: - void getPoint(void *object,gnuplot_point *point,int index,int pointCount); + void getPoint(void *object, gnuplot_point *point, int index, int pointCount); @param obj Pointer to an arbitrary object - @param point Pointer to the returned point struct (double x,y,z) - @param i Index of the current point (0 to n-1) + @param point Pointer to the returned point struct (double x, y, z) + @param i Index of the current point: 0 to n-1 @param n Number of points @return void - For example (where points is an array of points in this case): + Example: - void PlotPoint(void *obj, gnuplot_point *point, int i, int n) { - Point *p = (Point*) obj; - point->x = p[i].x; - point->y = p[i].y; - } + Here points is an array of points: - int main(int argc, char *argv[]) { - ... - gnuplot_plot_obj_xy(gp, points, PlotPoint, pCount, "Points"); - ... - } + @code + void PlotPoint(void *obj, gnuplot_point *point, int i, int n) { + Point *p = (Point*) obj; + point->x = p[i].x; + point->y = p[i].y; + } - Alternately, PlotPoint could return values based on a complex formula and many - sources of information. For example, it could be used to perform a Discrete - Fourier Transform on an array of complex numbers, calculating one transformed - point per call. + int main (int argc, char *argv[]) { + ... + gnuplot_plot_obj_xy(handle, points, PlotPoint, pCount, "Points"); + ... + } + @endcode + + Alternatively, PlotPoint could return values based on a complex formula and + many sources of information. For example, it could be used to perform a + Discrete Fourier Transform on an array of complex numbers, calculating one + transformed point per call. Note: always explicitly set all relevant parts of the struct. However, the z component for 2D plots can be ignored. @@ -910,7 +953,17 @@ int gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void char name[128]; char cmd[GP_CMD_SIZE]; - if (handle == NULL || getPoint == NULL || (n < 1)) return 1; + /* Trap errors on mandatory arguments */ + if (handle == NULL || getPoint == NULL || (n < 1)) { + fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); + return 1; + } + + /* Do not open a new gnuplot session if one is already open */ + if (handle->nplots > 0) { + fprintf(stderr, "A gnuplot session is already open and held by aother process"); + return 1; + } /* Open one more temporary file? */ if (handle->ntmp == GP_MAX_TMP_FILES - 1) { @@ -918,7 +971,7 @@ int gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void return 1; } - /* Open temporary file for output */ + /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); if ((tmpfd = mkstemp(name)) == -1) { fprintf(stderr, "Cannot create temporary file: exiting plot"); @@ -929,7 +982,7 @@ int gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void strcpy(handle->to_delete[handle->ntmp], name); handle->ntmp++; - /* Write data to this file */ + /* Write data to this file */ gnuplot_point point; for (int i = 0; i < n; i++) { getPoint(obj, &point, i, n); @@ -938,14 +991,14 @@ int gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void } close(tmpfd); - /* Command to be sent to gnuplot */ + /* Command to be sent to gnuplot */ if (title == NULL) { sprintf(cmd, "%s \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, handle->pstyle); } else { sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, title, handle->pstyle); } - /* Send command to gnuplot */ + /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; return 0; @@ -959,24 +1012,28 @@ int gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void @param label_x Label for X @param label_y Label for Y @param x Array of X coordinates - @param y Array of Y coordinates (can be NULL) + @param y Array of Y coordinates (can be NULL). @param n Number of values in x and y. @return void - This function opens a new gnuplot session, plots the provided - signal as an X or XY signal depending on a provided y, waits for - a carriage return on stdin and closes the session. + This function opens a new gnuplot session, plots the provided signal as an X + or XY signal depending on a provided y, waits for a carriage return on stdin + and closes the session. An empty title, empty style, or empty labels for X and Y may be provided. - Defaults are provided in this case. + Default valuess are provided in this case. */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, double *x, double *y, int n) { - gnuplot_ctrl *handle; // why is this a local variable? + /* Define handle as local variable to isolate itfrom other gnuplot sessions */ + gnuplot_ctrl *handle; + /* Some error trapping */ if (x == NULL || n < 1) return; if ((handle = gnuplot_init()) == NULL) return; + + /* Generate commands to send to gnuplot */ gnuplot_setstyle(handle, (style == NULL) ? "lines" : style); gnuplot_set_axislabel(handle, (label_x == NULL) ? 'X' : label_x, 'x'); gnuplot_set_axislabel(handle, (label_y == NULL) ? 'Y' : label_y, 'y'); @@ -997,11 +1054,12 @@ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, @param handle Gnuplot session control handle. @param a Slope. @param b Intercept. - @param title Title of the plot. + @param title Title of the plot (can be NULL). @return void @doc - Plot a slope on a gnuplot session. The provided equation has the form y=ax+b + Plot a slope on a gnuplot session. The general form of the equation is y=ax+b, + where only the slope a and intercept b are provided. Example: @@ -1022,7 +1080,7 @@ void gnuplot_plot_slope (gnuplot_ctrl *handle, double a, double b, char *title) char title_str[GP_TITLE_SIZE]; strcpy(title_str, (title == NULL) ? "no title" : title); - sprintf(cmd, "%s %g * x + %g title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", a, b, title, handle->pstyle); + sprintf(cmd, "%s %g * x + %g title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", a, b, title_str, handle->pstyle); gnuplot_cmd(handle, cmd); handle->nplots++; return; @@ -1033,22 +1091,22 @@ void gnuplot_plot_slope (gnuplot_ctrl *handle, double a, double b, char *title) @brief Plot a curve of given equation y=f(x). @param handle Gnuplot session control handle. @param equation Equation to plot. - @param title Title of the plot. + @param title Title of the plot (can be NULL). @return void - Plots out a curve of given equation. The general form of the - equation is y=f(x), by providing the f(x) side of the equation only. + Plots a curve of given equation. The general form of the equation is y=f(x), + by providing the f(x) side of the equation only. Example: @code - gnuplot_ctrl *h; - char eq[80]; + gnuplot_ctrl *h; + char eq[80]; - h = gnuplot_init(); - strcpy(eq, "sin(x) * cos(2*x)"); - gnuplot_plot_equation(h, eq, "sine wave", normal); - gnuplot_close(h); + h = gnuplot_init(); + strcpy(eq, "sin(x) * cos(2*x)"); + gnuplot_plot_equation(h, eq, "Sine wave", normal); + gnuplot_close(h); @endcode */ /*--------------------------------------------------------------------------*/ @@ -1071,23 +1129,24 @@ void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title) { @brief Save a graph as a Postscript file on storage @param handle Gnuplot session control handle. @param filename Filename to write to. - @param color + @param color Any character to retain colors, no colors if NULL @return void - A wrapper for the gnuplot_cmd function that sets the terminal to Postscript, - replots the graph and then resets the terminal to x11. + Sets the terminal to Postscript, replots the graph and then resets the + terminal back to x11. The use of this function supposes that it will be used + in combination with one of the plotting functions, see example. Example: @code - gnuplot_ctrl *h; - char eq[80]; - - h = gnuplot_init(); - strcpy(eq, "sin(x) * cos(2*x)"); - gnuplot_plot_equation(h, eq, "sine wave", normal); - gnuplot_hardcopy(h, "sinewave.ps"); - gnuplot_close(h); + gnuplot_ctrl *h; + char eq[80]; + + h = gnuplot_init(); + strcpy(eq, "sin(x) * cos(2*x)"); + gnuplot_plot_equation(h, eq, "Sine wave", normal); + gnuplot_hardcopy(h, "sinewave.ps"); + gnuplot_close(h); @endcode */ /*--------------------------------------------------------------------------*/ From a54dcb95cfe0e6c9837128a68f132f1854f20056 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Mon, 29 May 2023 22:05:41 +0200 Subject: [PATCH 008/128] Update README.md --- README.md | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 09cb65d..0dd73c9 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,34 @@ -gnuplot interface to C -====================== +gnuplot C library interface +=========================== -This is a modification of the `gnuplot_i` library by Nicolas Devillard, which adds the following functionality: +This is a modification of the gnuplot_i library by Nicolas Devillard, with the following enhancements: -* 3D plots, using `gnuplot_splot(handle, x, y, z, n, "title")` -* Set z-axis labels with `gnuplot_set_zlabel(handle, "z-axis label")` -* Produce color PostScript files with `gnuplot_hardcopy_colour(handle, "graph.ps")` -* Windows support, added in September 2005 -* Plot complex structures through the use of callbacks, see `gnuplot_plot_obj_xy` and `gnuplot_splot_obj` -* Contour plotting, using `gnuplot_setstyle(handle, "lines")` and `gnuplot_contour_plot(handle, x, y, z, nx, ny, "title")` +* 3D plots, using gnuplot_splot(handle, x, y, z, n, "title"). +* Setting z-axis labels with gnuplot_set_zlabel(handle, "z-axis label"). +* Production of colour PostScript files with gnuplot_hardcopy_colour(handle, "graph.ps"). +* Windows support. +* On OS X, if DISPLAY environment variable is not set, or USE_AQUA=1, then aqua is used instead of x11. +* Plotting of complex structures through the use of callbacks, see gnuplot_plot_obj_xy and gnuplot_splot_obj. +* Contour plotting with gnuplot_setstyle(handle, "lines") and gnuplot_contour_plot(handle, x, y, z, nx, ny, "title"). If you have any questions or comments, these can be sent to robert.bradley@merton.oxon.org, or via my website (http://www.robert-bradley.co.uk). + Changelog --------- -2nd April 2006 - Added gnuplot_splot_grid for plotting 2D arrays of data, and restored the lost contour plotting code. +29 May 2023 - Refactoring, stylistic improvements + +02 Apr 2006 - Added gnuplot_splot_grid for plotting 2D arrays of data, and restored the lost contour plotting code. -13th March 2006 - Fixed "bus error" under OS X when not using X11 and USE_AQUA environment variable is not set. +13 Mar 2006 - Fixed "bus error" under OS X when not using X11 and USE_AQUA environment variable is not set. -23rd November 2005 - gnuplot_contour_plot added (plots contours, use gnuplot_setstyle to set the contour style) +23 Nov 2005 - gnuplot_contour_plot added (plots contours, use gnuplot_setstyle to set the contour style) -15th September 2005 - Added possible OS X support, plus the gnuplot_plot_obj_xy and gnuplot_splot_obj functions. +15 Sep 2005 - Added possible OS X support, plus the gnuplot_plot_obj_xy and gnuplot_splot_obj functions. -11th September 2005 - Windows support added +11 Sep 2005 - Windows support added -14th August 2005 - included fixes from the official version 2.10 +14 Aug 2005 - Included fixes from the official version 2.10 -2nd November 2004 - initial version uploaded (based on gnuplot_i v2.6) +02 Nov 2004 - Initial version uploaded (based on gnuplot_i v2.6) From 74dfe6d16717a4e0c3e82a00934ec6377216b56a Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Mon, 29 May 2023 22:06:42 +0200 Subject: [PATCH 009/128] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0dd73c9..2f66e35 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ gnuplot C library interface This is a modification of the gnuplot_i library by Nicolas Devillard, with the following enhancements: -* 3D plots, using gnuplot_splot(handle, x, y, z, n, "title"). -* Setting z-axis labels with gnuplot_set_zlabel(handle, "z-axis label"). -* Production of colour PostScript files with gnuplot_hardcopy_colour(handle, "graph.ps"). +* 3D plots, using `gnuplot_splot(handle, x, y, z, n, "title")`. +* Setting z-axis labels with `gnuplot_set_zlabel(handle, "z-axis label")`. +* Production of colour PostScript files with `gnuplot_hardcopy_colour(handle, "graph.ps")`. * Windows support. * On OS X, if DISPLAY environment variable is not set, or USE_AQUA=1, then aqua is used instead of x11. -* Plotting of complex structures through the use of callbacks, see gnuplot_plot_obj_xy and gnuplot_splot_obj. -* Contour plotting with gnuplot_setstyle(handle, "lines") and gnuplot_contour_plot(handle, x, y, z, nx, ny, "title"). +* Plotting of complex structures through the use of callbacks, see `gnuplot_plot_obj_xy` and `gnuplot_splot_obj`. +* Contour plotting with `gnuplot_setstyle(handle, "lines")` and `gnuplot_contour_plot(handle, x, y, z, nx, ny, "title")`. If you have any questions or comments, these can be sent to robert.bradley@merton.oxon.org, or via my website (http://www.robert-bradley.co.uk). From 85d5e11747f262ee6809f0dbc4c0100311fb4734 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Mon, 29 May 2023 22:07:51 +0200 Subject: [PATCH 010/128] Update gnuplot_i.h * Remove code comments: duplicate from C file * Add comment headings --- gnuplot_i.h | 626 +++++----------------------------------------------- 1 file changed, 60 insertions(+), 566 deletions(-) diff --git a/gnuplot_i.h b/gnuplot_i.h index 68e9dd4..0eb7a6a 100755 --- a/gnuplot_i.h +++ b/gnuplot_i.h @@ -1,38 +1,23 @@ - -/*-------------------------------------------------------------------------*/ /** - @file gnuplot_i.h - @author N. Devillard - @date Sep 1998, Oct 2004, Sept 2005, Nov 2005, Apr 2006 - @version $Revision: 1.11.3 $ - @brief C interface to gnuplot. - - gnuplot is a freely available, command-driven graphical display tool for - Unix. It compiles and works quite well on a number of Unix flavours as - well as other operating systems. The following module enables sending - display requests to gnuplot through simple C calls. - - set_zlabel, splot and hardcopy_colour functions are based on existing code, - and added on 12 October 2004 by Robert Bradley (robert.bradley@merton.ox.ac.uk). - OS X and limited Windows support added 11-13th September 2005 - on Windows, - pgnuplot and wgnuplot.exe must be in the current directory. - - gnuplot_splot_grid added 2nd April 2006 (R. Bradley). + @file gnuplot_i.h + @author N. Devillard + @date Sep 1998, Oct 2004, Sept 2005, Nov 2005, Apr 2006 + @version $Revision: 1.11.3 $ + @brief C header file to gnuplot interface. */ -/*--------------------------------------------------------------------------*/ /* - $Id: gnuplot_i.h,v 1.11 2003/01/27 08:58:04 ndevilla Exp $ - $Author: ndevilla $ - $Date: 2003/01/27 08:58:04 $ - $Revision: 1.11.2 $ + $Id: gnuplot_i.h,v 1.11 2003/01/27 08:58:04 ndevilla Exp $ + $Author: ndevilla $ + $Date: 2003/01/27 08:58:04 $ + $Revision: 1.11.2 $ */ #ifndef _GNUPLOT_PIPES_H_ #define _GNUPLOT_PIPES_H_ /*--------------------------------------------------------------------------- - Includes + Includes ---------------------------------------------------------------------------*/ #include @@ -44,568 +29,77 @@ #include /** Maximal number of simultaneous temporary files */ -#define GP_MAX_TMP_FILES 64 +#define GP_MAX_TMP_FILES 64 /** Maximal size of a temporary file name */ -#define GP_TMP_NAME_SIZE 512 - +#define GP_TMP_NAME_SIZE 512 /*--------------------------------------------------------------------------- - New Types + New Types ---------------------------------------------------------------------------*/ -/*-------------------------------------------------------------------------*/ /** @typedef gnuplot_ctrl - @brief gnuplot session handle (opaque type). + @brief gnuplot session handle. - This structure holds all necessary information to talk to a gnuplot - session. It is built and returned by gnuplot_init() and later used - by all functions in this module to communicate with the session, then - meant to be closed by gnuplot_close(). + This structure holds all necessary information to talk to a gnuplot session. + It is built and returned by gnuplot_init() and later used by all functions + in this module to communicate with the session, then meant to be closed by + gnuplot_close(). - This structure is meant to remain opaque, you normally do not need - to know what is contained in there. + This structure is meant to remain opaque to the developer, so that its + contents are not to be directly used. */ -/*-------------------------------------------------------------------------*/ typedef struct _GNUPLOT_CTRL_ { - /** Pipe to gnuplot process */ - FILE * gnucmd ; - - /** Number of currently active plots */ - int nplots ; - /** Current plotting style */ - char pstyle[32] ; - /* Save terminal name (used by hardcopy functions) */ - char term[32] ; - - /** Name of temporary files */ - char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE] ; - /** Number of temporary files */ - int ntmp ; -} gnuplot_ctrl ; + FILE *gnucmd; /* Pipe to gnuplot process */ + int nplots; /* Number of currently active plots */ + char pstyle[32]; /* Current plotting style */ + char term[32]; /* Save terminal name (used by hardcopy functions) */ + char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE]; /* Name of temporary files */ + int ntmp; /* Number of temporary files */ +} gnuplot_ctrl; /* -gnuplot_point: Simple point struct to allow return of points to the -gnuplot_plot_obj_xy function by callback functions. + gnuplot_point: Simple point struct to allow return of points to the + `gnuplot_plot_obj_xy` function by callback functions. */ typedef struct _GNUPLOT_POINT_ { - double x; - double y; - double z; + double x; + double y; + double z; } gnuplot_point; - /*--------------------------------------------------------------------------- - Function ANSI C prototypes + Function ANSI C prototypes ---------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------*/ -/** - @brief Find out where a command lives in your PATH. - @param pname Name of the program to look for. - @return pointer to statically allocated character string. - - This is the C equivalent to the 'which' command in Unix. It parses - out your PATH environment variable to find out where a command - lives. The returned character string is statically allocated within - this function, i.e. there is no need to free it. Beware that the - contents of this string will change from one call to the next, - though (as all static variables in a function). - - The input character string must be the name of a command without - prefixing path of any kind, i.e. only the command name. The returned - string is the path in which a command matching the same name was - found. - - Examples (assuming there is a prog named 'hello' in the cwd): - - @verbatim - gnuplot_get_program_path("hello") returns "." - gnuplot_get_program_path("ls") returns "/bin" - gnuplot_get_program_path("csh") returns "/usr/bin" - gnuplot_get_program_path("/bin/ls") returns NULL - @endverbatim - - */ -/*-------------------------------------------------------------------------*/ -char * gnuplot_get_program_path(char * pname); - -/*-------------------------------------------------------------------------*/ -/** - @brief Opens up a gnuplot session, ready to receive commands. - @return Newly allocated gnuplot control structure. - - This opens up a new gnuplot session, ready for input. The struct - controlling a gnuplot session should remain opaque and only be - accessed through the provided functions. - - The session must be closed using gnuplot_close(). - */ -/*--------------------------------------------------------------------------*/ -gnuplot_ctrl * gnuplot_init(void); - -/*-------------------------------------------------------------------------*/ -/** - @brief Closes a gnuplot session previously opened by gnuplot_init() - @param handle Gnuplot session control handle. - @return void - - Kills the child PID and deletes all opened temporary files. - It is mandatory to call this function to close the handle, otherwise - temporary files are not cleaned and child process might survive. - - */ -/*--------------------------------------------------------------------------*/ -void gnuplot_close(gnuplot_ctrl * handle); - -/*-------------------------------------------------------------------------*/ -/** - @brief Sends a command to an active gnuplot session. - @param handle Gnuplot session control handle - @param cmd Command to send, same as a printf statement. - - This sends a string to an active gnuplot session, to be executed. - There is strictly no way to know if the command has been - successfully executed or not. - The command syntax is the same as printf. - - Examples: - - @code - gnuplot_cmd(g, "plot %d*x", 23.0); - gnuplot_cmd(g, "plot %g * cos(%g * x)", 32.0, -3.0); - @endcode - - Since the communication to the gnuplot process is run through - a standard Unix pipe, it is only unidirectional. This means that - it is not possible for this interface to query an error status - back from gnuplot. - */ -/*--------------------------------------------------------------------------*/ -void gnuplot_cmd(gnuplot_ctrl * handle, char * cmd, ...); - -/*-------------------------------------------------------------------------*/ -/** - @brief Change the plotting style of a gnuplot session. - @param h Gnuplot session control handle - @param plot_style Plotting-style to use (character string) - @return void - - The provided plotting style is a character string. It must be one of - the following: - - - lines - - points - - linespoints - - impulses - - dots - - steps - - errorbars - - boxes - - boxeserrorbars - */ -/*--------------------------------------------------------------------------*/ -void gnuplot_setstyle(gnuplot_ctrl * h, char * plot_style); - -/*-------------------------------------------------------------------------*/ -/** - @brief Change the terminal of a gnuplot session. - @param h Gnuplot session control handle - @param terminal Terminal name (character string) - @return void - - No attempt is made to check the validity of the terminal name. This function - simply makes a note of it and calls gnuplot_cmd to change the name - */ -/*--------------------------------------------------------------------------*/ - -void gnuplot_setterm(gnuplot_ctrl * h, char * terminal); - -/*-------------------------------------------------------------------------*/ -/** - @brief Sets the x label of a gnuplot session. - @param h Gnuplot session control handle. - @param label Character string to use for X label. - @return void - - Sets the x label for a gnuplot session. - */ -/*--------------------------------------------------------------------------*/ -void gnuplot_set_xlabel(gnuplot_ctrl * h, char * label); - - -/*-------------------------------------------------------------------------*/ -/** - @brief Sets the y label of a gnuplot session. - @param h Gnuplot session control handle. - @param label Character string to use for Y label. - @return void - - Sets the y label for a gnuplot session. - */ -/*--------------------------------------------------------------------------*/ -void gnuplot_set_ylabel(gnuplot_ctrl * h, char * label); - -/*-------------------------------------------------------------------------*/ -/** - @brief Sets the z label of a gnuplot session. - @param h Gnuplot session control handle. - @param label Character string to use for Z label. - @return void - - Sets the z label for a gnuplot session. - */ -/*--------------------------------------------------------------------------*/ -void gnuplot_set_zlabel(gnuplot_ctrl * h, char * label); - -/*-------------------------------------------------------------------------*/ -/** - @brief Resets a gnuplot session (next plot will erase previous ones). - @param h Gnuplot session control handle. - @return void - - Resets a gnuplot session, i.e. the next plot will erase all previous - ones. - */ -/*--------------------------------------------------------------------------*/ -void gnuplot_resetplot(gnuplot_ctrl * h); - - -/*-------------------------------------------------------------------------*/ -/** - @brief Plots a 2d graph from a list of doubles. - @param handle Gnuplot session control handle. - @param d Array of doubles. - @param n Number of values in the passed array. - @param title Title of the plot. - @return void - - Plots out a 2d graph from a list of doubles. The x-coordinate is the - index of the double in the list, the y coordinate is the double in - the list. - - Example: - - @code - gnuplot_ctrl *h ; - double d[50] ; - int i ; - - h = gnuplot_init() ; - for (i=0 ; i<50 ; i++) { - d[i] = (double)(i*i) ; - } - gnuplot_plot_x(h, d, 50, "parabola") ; - sleep(2) ; - gnuplot_close(h) ; - @endcode - */ -/*--------------------------------------------------------------------------*/ -void gnuplot_plot_x(gnuplot_ctrl * handle, double * d, int n, char * title); - -/*-------------------------------------------------------------------------*/ -/** - @brief Plot a 2d graph from a list of points. - @param handle Gnuplot session control handle. - @param x Pointer to a list of x coordinates. - @param y Pointer to a list of y coordinates. - @param n Number of doubles in x (assumed the same as in y). - @param title Title of the plot. - @return void - - Plots out a 2d graph from a list of points. Provide points through a list - of x and a list of y coordinates. Both provided arrays are assumed to - contain the same number of values. - - @code - gnuplot_ctrl *h ; - double x[50] ; - double y[50] ; - int i ; - - h = gnuplot_init() ; - for (i=0 ; i<50 ; i++) { - x[i] = (double)(i)/10.0 ; - y[i] = x[i] * x[i] ; - } - gnuplot_plot_xy(h, x, y, 50, "parabola") ; - sleep(2) ; - gnuplot_close(h) ; - @endcode - */ -/*--------------------------------------------------------------------------*/ -void gnuplot_plot_xy( - gnuplot_ctrl * handle, - double * x, - double * y, - int n, - char * title -) ; - -/*-------------------------------------------------------------------------*/ -/** - @brief Plot a 3d graph from a list of points. - @param handle Gnuplot session control handle. - @param x Pointer to a list of x coordinates. - @param y Pointer to a list of y coordinates. - @param z Pointer to a list of z coordinates. - @param n Number of doubles in x (assumed the same as in y and z). - @param title Title of the plot. - @return void - - Plots out a 3d graph from a list of points. Provide points through lists - of x, y and z coordinates. Both provided arrays are assumed to contain the - same number of values. -*/ -int gnuplot_splot( - gnuplot_ctrl * handle, - double * x, - double * y, - double * z, - int n, - char * title -) ; - -/*-------------------------------------------------------------------------*/ -/** - @brief Plot a 3d graph from a grid of points. - @param handle Gnuplot session control handle. - @param points Pointer to a grid of points (rows,cols). - @param rows Number of rows (y points). - @param cols Number of columns (x points). - @param title Title of the plot. - @return void - - gnuplot_splot_grid(handle,(double *) points,rows,cols,title); - Based on gnuplot_splot, modifications by Robert Bradley 2/4/2006 - - Plots a 3d graph from a grid of points, passed in the form of a 2D array [x,y]. - */ -/*--------------------------------------------------------------------------*/ - -int gnuplot_splot_grid(gnuplot_ctrl *handle, double *points, int rows, int cols, char *title); - -/*-------------------------------------------------------------------------*/ -/** - @brief Plot contours from a list of points. - @param handle Gnuplot session control handle. - @param x Pointer to a list of x coordinates. (length=nx*ny) - @param y Pointer to a list of y coordinates. (length=nx*ny) - @param z Pointer to a list of z coordinates. (length=nx*ny) - @param nx Number of doubles in x-direction - @param ny Number of doubles in y-direction - @param title Title of the plot. - @return void - - gnuplot_contour_plot(handle,x,y,z,n,title); - Based on gnuplot_splot, modifications by Robert Bradley 23/11/2005 - - Plots a contour plot from a list of points, passed in the form of three arrays x, y and z. - - @code - gnuplot_ctrl *h ; - double x[50] ; y[50] ; z[50]; - int i ; - - h = gnuplot_init() ; - int count=100; - double x[count*count],y[count*count],z[count*count]; - int i,j; - for (i=0;i Date: Mon, 29 May 2023 22:09:51 +0200 Subject: [PATCH 011/128] Delete gnuplot_i_example.c File will be uploaded in its own directory and renamed --- gnuplot_i_example.c | 124 -------------------------------------------- 1 file changed, 124 deletions(-) delete mode 100755 gnuplot_i_example.c diff --git a/gnuplot_i_example.c b/gnuplot_i_example.c deleted file mode 100755 index 7cfe9a4..0000000 --- a/gnuplot_i_example.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Examples of gnuplot_i.c usage - */ - -#include -#include -#include "gnuplot_i.h" - -#define SLEEP_LGTH 2 -#define NPOINTS 50 - -int main(int argc, char *argv[]) { - gnuplot_ctrl *h1, *h2, *h3, *h4; - double x[NPOINTS], y[NPOINTS]; - int i; - - /** Initialize the gnuplot handle */ - - printf("*** Example of gnuplot control through C ***\n"); - h1 = gnuplot_init(); - - /** Slopes */ - - gnuplot_setstyle(h1, "lines"); - printf("*** Plotting slopes\n"); - printf("y = x\n"); - gnuplot_plot_slope(h1, 1.0, 0.0, "unity slope"); - sleep(SLEEP_LGTH); - printf("y = 2*x\n"); - gnuplot_plot_slope(h1, 2.0, 0.0, "y=2x"); - sleep(SLEEP_LGTH); - printf("y = -x\n"); - gnuplot_plot_slope(h1, -1.0, 0.0, "y=-x"); - sleep(SLEEP_LGTH); - - /** Equations */ - - gnuplot_resetplot(h1); - printf("\n\n"); - printf("*** various equations\n"); - printf("y = sin(x)\n"); - gnuplot_plot_equation(h1, "sin(x)", "sine"); - sleep(SLEEP_LGTH); - printf("y = log(x)\n"); - gnuplot_plot_equation(h1, "log(x)", "logarithm"); - sleep(SLEEP_LGTH); - printf("y = sin(x)*cos(2*x)\n"); - gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product"); - sleep(SLEEP_LGTH); - - /** Styles */ - - gnuplot_resetplot(h1); - printf("\n\n"); - printf("*** showing styles\n"); - printf("sine in points\n"); - gnuplot_setstyle(h1, "points"); - gnuplot_plot_equation(h1, "sin(x)", "sine"); - sleep(SLEEP_LGTH); - printf("sine in impulses\n"); - gnuplot_setstyle(h1, "impulses"); - gnuplot_plot_equation(h1, "sin(x)", "sine"); - sleep(SLEEP_LGTH); - printf("sine in steps\n"); - gnuplot_setstyle(h1, "steps"); - gnuplot_plot_equation(h1, "sin(x)", "sine"); - sleep(SLEEP_LGTH); - - /** User defined 1d and 2d point sets */ - - gnuplot_resetplot(h1); - gnuplot_setstyle(h1, "impulses"); - printf("\n\n"); - printf("*** user-defined lists of doubles\n"); - for (i = 0; i < NPOINTS; i++) { - x[i] = (double)i * i; - } - gnuplot_plot_x(h1, x, NPOINTS, "user-defined doubles"); - sleep(SLEEP_LGTH); - printf("*** user-defined lists of points\n"); - for (i = 0; i < NPOINTS; i++) { - x[i] = (double)i; - y[i] = (double)i * (double)i; - } - gnuplot_resetplot(h1); - gnuplot_setstyle(h1, "points"); - gnuplot_plot_xy(h1, x, y, NPOINTS, "user-defined points"); - sleep(SLEEP_LGTH); - - /** Multiple output screens */ - - printf("\n\n"); - printf("*** multiple output windows\n"); - gnuplot_resetplot(h1); - gnuplot_setstyle(h1, "lines"); - h2 = gnuplot_init(); - gnuplot_setstyle(h2, "lines"); - h3 = gnuplot_init(); - gnuplot_setstyle(h3, "lines"); - h4 = gnuplot_init(); - gnuplot_setstyle(h4, "lines"); - printf("window 1: sin(x)\n"); - gnuplot_plot_equation(h1, "sin(x)", "sin(x)"); - sleep(SLEEP_LGTH); - printf("window 2: x*sin(x)\n"); - gnuplot_plot_equation(h2, "x*sin(x)", "x*sin(x)"); - sleep(SLEEP_LGTH); - printf("window 3: log(x)/x\n"); - gnuplot_plot_equation(h3, "log(x)/x", "log(x)/x"); - sleep(SLEEP_LGTH); - printf("window 4: sin(x)/x\n"); - gnuplot_plot_equation(h4, "sin(x)/x", "sin(x)/x"); - sleep(SLEEP_LGTH); - - /** Close gnuplot handles */ - - printf("\n\n"); - printf("*** end of gnuplot example\n"); - gnuplot_close(h1); - gnuplot_close(h2); - gnuplot_close(h3); - gnuplot_close(h4); - return 0; -} From ca68f8073665f3d9777f732591d3e52b7250268e Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Mon, 29 May 2023 22:17:50 +0200 Subject: [PATCH 012/128] Update README.md * Wording in heading --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f66e35..12fe71a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -gnuplot C library interface +gnuplot C interface library =========================== This is a modification of the gnuplot_i library by Nicolas Devillard, with the following enhancements: From 59e3b084dc9968452e5dd93110160035e26473fc Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Mon, 29 May 2023 22:30:09 +0200 Subject: [PATCH 013/128] Add files via upload --- examples/animation.c | 24 +++++++++ examples/example.c | 124 +++++++++++++++++++++++++++++++++++++++++++ examples/sinepng.c | 15 ++++++ 3 files changed, 163 insertions(+) create mode 100644 examples/animation.c create mode 100644 examples/example.c create mode 100644 examples/sinepng.c diff --git a/examples/animation.c b/examples/animation.c new file mode 100644 index 0000000..033a36b --- /dev/null +++ b/examples/animation.c @@ -0,0 +1,24 @@ +#include +#include +#include "gnuplot_i.h" + +int main(int argc, char *argv[]) { + gnuplot_ctrl *handle; + double phase; + + printf("*** example of gnuplot control through C ***\n"); + handle = gnuplot_init(); + + for (phase = 0.1; phase < 10; phase += 0.1) { + gnuplot_resetplot(handle); + gnuplot_cmd(handle, "plot sin(x+%g)", phase); + } + + for (phase = 10; phase> = 0.1; phase -= 0.1) { + gnuplot_resetplot(handle); + gnuplot_cmd(handle, "plot sin(x+%g)", phase); + } + + gnuplot_close(handle); + return 0; +} diff --git a/examples/example.c b/examples/example.c new file mode 100644 index 0000000..94b2e5a --- /dev/null +++ b/examples/example.c @@ -0,0 +1,124 @@ +/* + * Examples of gnuplot_i.c usage + */ + +#include +#include +#include "gnuplot_i.h" + +#define SLEEP_LGTH 2 +#define NPOINTS 50 + +int main(int argc, char *argv[]) { + gnuplot_ctrl *h1, *h2, *h3, *h4; + double x[NPOINTS], y[NPOINTS]; + int i; + + /** Initialize the gnuplot handle */ + + printf("*** Example of gnuplot control through C ***\n"); + h1 = gnuplot_init(); + + /** Slopes */ + + gnuplot_setstyle(h1, "lines"); + printf("*** plotting slopes\n"); + printf("y = x\n"); + gnuplot_plot_slope(h1, 1.0, 0.0, "unity slope"); + sleep(SLEEP_LGTH); + printf("y = 2*x\n"); + gnuplot_plot_slope(h1, 2.0, 0.0, "y=2x"); + sleep(SLEEP_LGTH); + printf("y = -x\n"); + gnuplot_plot_slope(h1, -1.0, 0.0, "y=-x"); + sleep(SLEEP_LGTH); + + /** Equations */ + + gnuplot_resetplot(h1); + printf("\n\n"); + printf("*** various equations\n"); + printf("y = sin(x)\n"); + gnuplot_plot_equation(h1, "sin(x)", "sine"); + sleep(SLEEP_LGTH); + printf("y = log(x)\n"); + gnuplot_plot_equation(h1, "log(x)", "logarithm"); + sleep(SLEEP_LGTH); + printf("y = sin(x)*cos(2*x)\n"); + gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product"); + sleep(SLEEP_LGTH); + + /** Styles */ + + gnuplot_resetplot(h1); + printf("\n\n"); + printf("*** showing styles\n"); + printf("sine in points\n"); + gnuplot_setstyle(h1, "points"); + gnuplot_plot_equation(h1, "sin(x)", "sine"); + sleep(SLEEP_LGTH); + printf("sine in impulses\n"); + gnuplot_setstyle(h1, "impulses"); + gnuplot_plot_equation(h1, "sin(x)", "sine"); + sleep(SLEEP_LGTH); + printf("sine in steps\n"); + gnuplot_setstyle(h1, "steps"); + gnuplot_plot_equation(h1, "sin(x)", "sine"); + sleep(SLEEP_LGTH); + + /** User defined 1d and 2d point sets */ + + gnuplot_resetplot(h1); + gnuplot_setstyle(h1, "impulses"); + printf("\n\n"); + printf("*** user-defined lists of doubles\n"); + for (i = 0; i < NPOINTS; i++) { + x[i] = (double)i * i; + } + gnuplot_plot_x(h1, x, NPOINTS, "user-defined doubles"); + sleep(SLEEP_LGTH); + printf("*** user-defined lists of points\n"); + for (i = 0; i < NPOINTS; i++) { + x[i] = (double)i; + y[i] = (double)i * (double)i; + } + gnuplot_resetplot(h1); + gnuplot_setstyle(h1, "points"); + gnuplot_plot_xy(h1, x, y, NPOINTS, "user-defined points"); + sleep(SLEEP_LGTH); + + /** Multiple output screens */ + + printf("\n\n"); + printf("*** multiple output windows\n"); + gnuplot_resetplot(h1); + gnuplot_setstyle(h1, "lines"); + h2 = gnuplot_init(); + gnuplot_setstyle(h2, "lines"); + h3 = gnuplot_init(); + gnuplot_setstyle(h3, "lines"); + h4 = gnuplot_init(); + gnuplot_setstyle(h4, "lines"); + printf("window 1: sin(x)\n"); + gnuplot_plot_equation(h1, "sin(x)", "sin(x)"); + sleep(SLEEP_LGTH); + printf("window 2: x*sin(x)\n"); + gnuplot_plot_equation(h2, "x*sin(x)", "x*sin(x)"); + sleep(SLEEP_LGTH); + printf("window 3: log(x)/x\n"); + gnuplot_plot_equation(h3, "log(x)/x", "log(x)/x"); + sleep(SLEEP_LGTH); + printf("window 4: sin(x)/x\n"); + gnuplot_plot_equation(h4, "sin(x)/x", "sin(x)/x"); + sleep(SLEEP_LGTH); + + /** Close gnuplot handles */ + + printf("\n\n"); + printf("*** end of gnuplot example\n"); + gnuplot_close(h1); + gnuplot_close(h2); + gnuplot_close(h3); + gnuplot_close(h4); + return 0; +} diff --git a/examples/sinepng.c b/examples/sinepng.c new file mode 100644 index 0000000..39f50cd --- /dev/null +++ b/examples/sinepng.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include +#include "gnuplot_i.h" + +int main(int argc, char * argv[]) { + gnuplot_ctrl *handle = gnuplot_init(); + gnuplot_cmd(handle, "set terminal png"); + gnuplot_cmd(handle, "set output \"sine.png\""); + gnuplot_plot_equation(handle, "sin(x)", "Sine wave"); + gnuplot_close(handle); + + return 0 ; +} From 3cdd78ba7ee956a6beac7c585bd6e2ea0491b108 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 30 May 2023 11:02:13 +0200 Subject: [PATCH 014/128] Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 12fe71a..1f21716 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ gnuplot C interface library =========================== -This is a modification of the gnuplot_i library by Nicolas Devillard, with the following enhancements: +This is a modification of the gnuplot_i library by Nicolas Devillard, which enables developers to create gnuplots from their C programs. It features the following enhancements: * 3D plots, using `gnuplot_splot(handle, x, y, z, n, "title")`. * Setting z-axis labels with `gnuplot_set_zlabel(handle, "z-axis label")`. @@ -32,3 +32,10 @@ Changelog 14 Aug 2005 - Included fixes from the official version 2.10 02 Nov 2004 - Initial version uploaded (based on gnuplot_i v2.6) + + +Documentation +------------- + +Documentation of macros, includes, functions and prototypes can be straightforwardly generated using doxygen /doxywizard. + From 68dc501762785db5af1168415970a3e608baccd1 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 30 May 2023 11:03:41 +0200 Subject: [PATCH 015/128] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f21716..967dc54 100644 --- a/README.md +++ b/README.md @@ -37,5 +37,5 @@ Changelog Documentation ------------- -Documentation of macros, includes, functions and prototypes can be straightforwardly generated using doxygen /doxywizard. +Documentation of macros, includes, functions and prototypes can be straightforwardly generated using [https://www.doxygen.nl doxygen] / doxywizard. From 757c02c0624da1345809d4c71e2ed20d211863a8 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 30 May 2023 11:07:24 +0200 Subject: [PATCH 016/128] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 967dc54..da78422 100644 --- a/README.md +++ b/README.md @@ -37,5 +37,4 @@ Changelog Documentation ------------- -Documentation of macros, includes, functions and prototypes can be straightforwardly generated using [https://www.doxygen.nl doxygen] / doxywizard. - +Documentation of macros, includes, functions and prototypes can be straightforwardly generated using [doxygen](https://www.doxygen.nl) and/or the [doxywizard](https://www.doxygen.nl/manual/doxywizard_usage.html). From f2b85f937b4fca2d2827fb874bb8886e29f56e08 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 30 May 2023 16:00:47 +0200 Subject: [PATCH 017/128] Update gnuplot_i.c * Simplify error handling * Return type `void` throughout * Code comment updates --- gnuplot_i.c | 310 ++++++++++++++++------------------------------------ 1 file changed, 93 insertions(+), 217 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index 38a06c8..f205b7d 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -32,14 +32,16 @@ Defines ---------------------------------------------------------------------------*/ -/** Maximal size of a gnuplot command */ +/** Maximum amount of characters of a gnuplot command */ #define GP_CMD_SIZE 2048 -/** Maximal size of a plot title */ +/** Maximum amount of characters of a plot title */ #define GP_TITLE_SIZE 80 -/** Maximal size for an equation */ +/** Maximum amount of characters for an equation */ #define GP_EQ_SIZE 512 -/** Maximal size of a name in the PATH */ +/** Maximum amount of characters of a name in the PATH */ #define PATH_MAXNAMESZ 4096 +/** Error message display */ +#define FAIL_IF(EXP, MSG) ({ if (EXP) { printf("ERROR: " MSG "\n"); exit(EXIT_FAILURE); }}) #ifdef _WIN32 #undef P_tmpdir @@ -64,18 +66,26 @@ #include #include -int mkstemp (char *templ) { +/*-------------------------------------------------------------------------*/ +/** + @brief Create temporary output pipe with randomised name. + @param name Name of the pipe. + @return int + */ +/*-------------------------------------------------------------------------*/ + +int mkstemp (char *name) { srand(time(NULL)); int i; - char *start = strstr(templ, "XXXXXX"); + char *start = strstr(name, "XXXXXX"); for (i = 0; i < 6; i++) { - start[i] = (char) (48 + ((int) rand() * 10 / 32768.0)); + start[i] = (char) (48 + ((int) rand() * 10 / 32768.0)); // 16-bits solution only? } - i = open(templ, O_RDWR | O_CREAT); + i = open(name, O_RDWR | O_CREAT); if (i != -1) { - DWORD dwFileAttr = GetFileAttributes(templ); - SetFileAttributes(templ, dwFileAttr & !FILE_ATTRIBUTE_READONLY); + DWORD dwFileAttr = GetFileAttributes(name); + SetFileAttributes(name, dwFileAttr & !FILE_ATTRIBUTE_READONLY); } return i; } @@ -125,25 +135,22 @@ char *gnuplot_get_program_path (char *pname) { /* Try in all paths given in the PATH variable */ buf[0] = 0; path = getenv("PATH"); - if (path != NULL) { - for (i = 0; path[i]; ) { - for (j = i; (path[j]) && (path[j] != ':'); j++); - lg = j - i; - strncpy(buf, path + i, lg); - if (lg == 0) buf[lg++] = '.'; - buf[lg++] = '/'; - strcpy(buf + lg, pname); - if (access(buf, X_OK) == 0) /* Found it! */ break; - buf[0] = 0; - i = j; - if (path[i] == ':') i++; - } - } else { - fprintf(stderr, "PATH variable not set\n"); + FAIL_IF ((path != NULL), "PATH variable not set"); + for (i = 0; path[i]; ) { + for (j = i; (path[j]) && (path[j] != ':'); j++); + lg = j - i; + strncpy(buf, path + i, lg); + if (lg == 0) buf[lg++] = '.'; + buf[lg++] = '/'; + strcpy(buf + lg, pname); + if (access(buf, X_OK) == 0) /* Found it! */ break; + buf[0] = 0; + i = j; + if (path[i] == ':') i++; } - /* If the buffer is still empty, the command was not found */ - if (buf[0] == 0) return NULL; + /* If the buffer is still empty, then the command was not found */ + FAIL_IF (buf[0] == 0, "Command not found in PATH variable"); /* Otherwise truncate the command name to yield path only */ lg = strlen(buf) - 1; @@ -172,21 +179,13 @@ gnuplot_ctrl *gnuplot_init (void) { gnuplot_ctrl *handle; #ifndef _WIN32 #ifndef __APPLE__ - if (getenv("DISPLAY") == NULL) { - fprintf(stderr, "Cannot find DISPLAY variable: is it set?\n"); - } + FAIL_IF (getenv("DISPLAY") == NULL, "Cannot find DISPLAY variable: has it been set?"); #endif #endif #ifndef _WIN32 - if (gnuplot_get_program_path("gnuplot") == NULL) { - fprintf(stderr, "Cannot find gnuplot in your PATH"); - return NULL; - } + FAIL_IF (gnuplot_get_program_path("gnuplot") == NULL, "Cannot find gnuplot in your PATH"); #endif - if (gnuplot_get_program_path(GNUPLOT_EXEC) == NULL) { - fprintf(stderr, "Cannot find gnuplot in your PATH"); - return NULL; - } + FAIL_IF (gnuplot_get_program_path(GNUPLOT_EXEC) == NULL, "Cannot find gnuplot in your PATH"); /* Structure initialization: */ handle = (gnuplot_ctrl *)malloc(sizeof(gnuplot_ctrl)); @@ -195,10 +194,11 @@ gnuplot_ctrl *gnuplot_init (void) { handle->ntmp = 0; handle->gnucmd = popen(GNUPLOT_EXEC, "w"); if (handle->gnucmd == NULL) { - fprintf(stderr, "Error starting gnuplot\n"); free(handle); - return NULL; + FAIL_IF (0 == 0, "Error starting gnuplot"); } + + /* Set terminal output type */ #ifdef _WIN32 gnuplot_setterm(handle, "windows"); #elif __APPLE__ @@ -227,16 +227,12 @@ gnuplot_ctrl *gnuplot_init (void) { /*--------------------------------------------------------------------------*/ void gnuplot_close (gnuplot_ctrl *handle) { - if (pclose(handle->gnucmd) == -1) { - fprintf(stderr, "Cannot close communication to gnuplot\n"); - return; - } + FAIL_IF (pclose(handle->gnucmd) == -1, "Cannot close communication to gnuplot"); if (handle->ntmp) { for (int i = 0; i < handle->ntmp; i++) { #ifdef _WIN32 int x = remove(handle->to_delete[i]); - if (x) - printf("Cannot delete %s: error number %d\n", handle->to_delete[i], errno); + if (x) printf("Cannot delete %s: error number %d\n", handle->to_delete[i], errno); #else remove(handle->to_delete[i]); #endif @@ -327,8 +323,12 @@ void gnuplot_setstyle (gnuplot_ctrl *handle, char *plot_style) { @param terminal Terminal name (character string) @return void + In gnuplot the terminal type is the output channel to which the plot should be + displayed on. This is typically 'x11' for Linux, 'acqua' for OSX or either + 'wxt' or 'windows' for MS-Windows. + No attempt is made to check the validity of the terminal name. This function - simply makes a note of it and calls gnuplot_cmd to change the name. + simply makes a note of it and calls `gnuplot_cmd` to change the name. */ /*--------------------------------------------------------------------------*/ @@ -358,7 +358,6 @@ void gnuplot_set_axislabel (gnuplot_ctrl *handle, char *label, char *axis) { sprintf(cmd, "set %slabel \"%s\"", axis, label); gnuplot_cmd(handle, cmd); - return; } /*-------------------------------------------------------------------------*/ @@ -379,7 +378,6 @@ void gnuplot_resetplot (gnuplot_ctrl *handle) { } handle->ntmp = 0; handle->nplots = 0; - return; } /*-------------------------------------------------------------------------*/ @@ -416,30 +414,14 @@ void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title) { char name[128]; char cmd[GP_CMD_SIZE]; - /* Trap errors on mandatory arguments */ - if (handle == NULL || x == NULL || (n < 1)) { - fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); - return; - } - - /* Do not open a new gnuplot session if one is already open */ - if (handle->nplots > 0) { - fprintf(stderr, "A gnuplot session is already open and held by aother process"); - return; - } - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); - return; - } + /* Error handling: mandatory arguments, already open session, opening temporary file */ + FAIL_IF (handle == NULL || x == NULL || (n < 1), "One of the parameters has been misspecified"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd = mkstemp(name)) == -1) { - fprintf(stderr, "Cannot create temporary file: exiting plot"); - return; - } + FAIL_IF ((tmpfd = mkstemp(name)) == -1, "Cannot create temporary file: exiting plot"); /* Store file name in array for future deletion */ strcpy(handle->to_delete[handle->ntmp], name); @@ -462,7 +444,6 @@ void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title) { /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; - return; } /*-------------------------------------------------------------------------*/ @@ -503,29 +484,13 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t char cmd[GP_CMD_SIZE]; /* Trap errors on mandatory arguments */ - if (handle == NULL || x == NULL || y == NULL || (n < 1)) { - fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); - return; - } - - /* Do not open a new gnuplot session if one is already open */ - if (handle->nplots > 0) { - fprintf(stderr, "A gnuplot session is already open and held by aother process"); - return; - } - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); - return; - } + FAIL_IF (handle == NULL || x == NULL || y == NULL || (n < 1), "One of the parameters has been misspecified"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd = mkstemp(name)) == -1) { - fprintf(stderr, "Cannot create temporary file: exiting plot"); - return; - } + FAIL_IF ((tmpfd = mkstemp(name)) == -1, "Cannot create temporary file: exiting plot"); /* Store file name in array for future deletion */ strcpy(handle->to_delete[handle->ntmp], name); @@ -548,7 +513,6 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; - return; } /*-------------------------------------------------------------------------*/ @@ -560,9 +524,9 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t @param z Pointer to a list of z coordinates. @param n Number of doubles in x (same for y and z). @param title Title of the plot (can be NULL). - @return int 1 if error encountered, 0 otherwise + @return void - Based on gnuplot_plot_xy, modifications by Robert Bradley 12/10/2004 + Based on `gnuplot_plot_xy`, modifications by Robert Bradley 12/10/2004 Plots a 3d graph from a list of points, passed as arrays x, y and z. All arrays are assumed to contain the same number of values. @@ -586,35 +550,19 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t */ /*--------------------------------------------------------------------------*/ -int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char *title) { +void gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char *title) { int tmpfd; char name[128]; char cmd[GP_CMD_SIZE]; /* Trap errors on mandatory arguments */ - if (handle == NULL || x == NULL || y == NULL || (n < 1)) { - fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); - return 1; - } - - /* Do not open a new gnuplot session if one is already open */ - if (handle->nplots > 0) { - fprintf(stderr, "A gnuplot session is already open and held by aother process"); - return 1; - } - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); - return 1; - } + FAIL_IF (handle == NULL || x == NULL || y == NULL || (n < 1), "One of the parameters has been misspecified"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd = mkstemp(name)) == -1) { - fprintf(stderr, "Cannot create temporary file: exiting plot"); - return 1; - } + FAIL_IF ((tmpfd = mkstemp(name)) == -1, "Cannot create temporary file: exiting plot"); /* Store file name in array for future deletion */ strcpy(handle->to_delete[handle->ntmp], name); @@ -637,7 +585,6 @@ int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; - return 0; } /*-------------------------------------------------------------------------*/ @@ -648,7 +595,7 @@ int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, @param rows Number of rows (y points). @param cols Number of columns (x points). @param title Title of the plot (can be NULL). - @return int 1 if error encountered, 0 otherwise + @return void Example: @@ -662,35 +609,19 @@ int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, */ /*--------------------------------------------------------------------------*/ -int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols, char *title) { +void gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols, char *title) { int tmpfd; char name[128]; char cmd[GP_CMD_SIZE]; /* Trap errors on mandatory arguments */ - if (handle == NULL || points == NULL || (rows < 1) || (cols < 1)) { - fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); - return 1; - } - - /* Do not open a new gnuplot session if one is already open */ - if (handle->nplots > 0) { - fprintf(stderr, "A gnuplot session is already open and held by aother process"); - return 1; - } - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); - return 1; - } + FAIL_IF (handle == NULL || points == NULL || (rows < 1) || (cols < 1), "One of the parameters has been misspecified"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd = mkstemp(name)) == -1) { - fprintf(stderr, "Cannot create temporary file: exiting plot"); - return 1; - } + FAIL_IF ((tmpfd = mkstemp(name)) == -1, "Cannot create temporary file: exiting plot"); /* Store file name in array for future deletion */ strcpy(handle->to_delete[handle->ntmp], name); @@ -717,7 +648,6 @@ int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; - return 0; } /*-------------------------------------------------------------------------*/ @@ -730,9 +660,9 @@ int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols @param nx Number of doubles in x-direction. @param ny Number of doubles in y-direction. @param title Title of the plot (can be NULL). - @return int 1 if error encountered, 0 otherwise + @return void - Based on gnuplot_splot, modifications by Robert Bradley 23/11/2005 + Based on `gnuplot_splot`, modifications by Robert Bradley 23/11/2005 Plots a contour plot from a list of points, passed as arrays x, y and z. @@ -760,35 +690,19 @@ int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols */ /*--------------------------------------------------------------------------*/ -int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, int nx, int ny, char *title) { +void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, int nx, int ny, char *title) { int tmpfd; char name[128]; char cmd[GP_CMD_SIZE]; /* Trap errors on mandatory arguments */ - if (handle == NULL || x == NULL || y == NULL || (nx < 1) || (ny < 1)) { - fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); - return 1; - } - - /* Do not open a new gnuplot session if one is already open */ - if (handle->nplots > 0) { - fprintf(stderr, "A gnuplot session is already open and held by aother process"); - return 1; - } - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); - return 1; - } + FAIL_IF (handle == NULL || x == NULL || y == NULL || (nx < 1) || (ny < 1), "One of the parameters has been misspecified"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd = mkstemp(name)) == -1) { - fprintf(stderr, "Cannot create temporary file: exiting plot"); - return 1; - } + FAIL_IF ((tmpfd = mkstemp(name)) == -1, "Cannot create temporary file: exiting plot"); /* Store file name in array for future deletion */ strcpy(handle->to_delete[handle->ntmp], name); @@ -820,18 +734,17 @@ int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; - return 0; } /*-------------------------------------------------------------------------*/ /** - @brief Plot a 3d graph using callback functions to return the points + @brief Plot a 3d graph using callback functions to return the points. @param handle Gnuplot session control handle. @param obj Pointer to an arbitrary object. @param getPoint Pointer to a callback function. @param n Number of doubles in x (y and z must be the the same). @param title Title of the plot (can be NULL). - @return int 1 if error encountered, 0 otherwise + @return void Calback: @@ -844,35 +757,19 @@ int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, */ /*--------------------------------------------------------------------------*/ -int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title) { +void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title) { int tmpfd; char name[128]; char cmd[GP_CMD_SIZE]; /* Trap errors on mandatory arguments */ - if (handle == NULL || getPoint == NULL || (n < 1)) { - fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); - return 1; - } - - /* Do not open a new gnuplot session if one is already open */ - if (handle->nplots > 0) { - fprintf(stderr, "A gnuplot session is already open and held by aother process"); - return 1; - } - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); - return 1; - } + FAIL_IF (handle == NULL || getPoint == NULL || (n < 1), "One of the parameters has been misspecified"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd = mkstemp(name)) == -1) { - fprintf(stderr, "Cannot create temporary file: exiting plot"); - return 1; - } + FAIL_IF ((tmpfd = mkstemp(name)) == -1, "Cannot create temporary file: exiting plot"); /* Store file name in array for future deletion */ strcpy(handle->to_delete[handle->ntmp], name); @@ -897,7 +794,6 @@ int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; - return 0; } /*-------------------------------------------------------------------------*/ @@ -908,7 +804,7 @@ int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, @param getPoint Pointer to a callback function. @param n Number of points. @param title Title of the plot (can be NULL). - @return int 1 if error encountered, 0 otherwise + @return void The callback function is of the following form, and is called once for each point plotted: @@ -922,7 +818,7 @@ int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, Example: - Here points is an array of points: + Here `points` is an array of points: @code void PlotPoint(void *obj, gnuplot_point *point, int i, int n) { @@ -948,35 +844,19 @@ int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, */ /*-------------------------------------------------------------------------*/ -int gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title) { +void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title) { int tmpfd; char name[128]; char cmd[GP_CMD_SIZE]; /* Trap errors on mandatory arguments */ - if (handle == NULL || getPoint == NULL || (n < 1)) { - fprintf(stderr, "One of the parameters to `%s` has been misspecified", __func__); - return 1; - } - - /* Do not open a new gnuplot session if one is already open */ - if (handle->nplots > 0) { - fprintf(stderr, "A gnuplot session is already open and held by aother process"); - return 1; - } - - /* Open one more temporary file? */ - if (handle->ntmp == GP_MAX_TMP_FILES - 1) { - fprintf(stderr, "Maximum number of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES); - return 1; - } + FAIL_IF (handle == NULL || getPoint == NULL || (n < 1), "One of the parameters has been misspecified"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ sprintf(name, GNUPLOT_TEMPFILE, P_tmpdir); - if ((tmpfd = mkstemp(name)) == -1) { - fprintf(stderr, "Cannot create temporary file: exiting plot"); - return 1; - } + FAIL_IF ((tmpfd = mkstemp(name)) == -1, "Cannot create temporary file: exiting plot"); /* Store file name in array for future deletion */ strcpy(handle->to_delete[handle->ntmp], name); @@ -1001,7 +881,6 @@ int gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); handle->nplots++; - return 0; } /*-------------------------------------------------------------------------*/ @@ -1035,8 +914,8 @@ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, /* Generate commands to send to gnuplot */ gnuplot_setstyle(handle, (style == NULL) ? "lines" : style); - gnuplot_set_axislabel(handle, (label_x == NULL) ? 'X' : label_x, 'x'); - gnuplot_set_axislabel(handle, (label_y == NULL) ? 'Y' : label_y, 'y'); + gnuplot_set_axislabel(handle, (label_x == NULL) ? "X" : label_x, "x"); + gnuplot_set_axislabel(handle, (label_y == NULL) ? "Y" : label_y, "y"); if (y == NULL) { gnuplot_plot_x(handle, x, n, title); } else { @@ -1045,7 +924,6 @@ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, printf("Press Enter to continue\n"); while (getchar() != '\n') {} gnuplot_close(handle); - return; } /*-------------------------------------------------------------------------*/ @@ -1083,7 +961,6 @@ void gnuplot_plot_slope (gnuplot_ctrl *handle, double a, double b, char *title) sprintf(cmd, "%s %g * x + %g title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", a, b, title_str, handle->pstyle); gnuplot_cmd(handle, cmd); handle->nplots++; - return; } /*-------------------------------------------------------------------------*/ @@ -1121,12 +998,11 @@ void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title) { sprintf(cmd, "%s %s title \"%s\" with %s", plot_str, equation, title_str, handle->pstyle); gnuplot_cmd(handle, cmd); handle->nplots++; - return; } /*-------------------------------------------------------------------------*/ /** - @brief Save a graph as a Postscript file on storage + @brief Save a graph as a Postscript file on storage. @param handle Gnuplot session control handle. @param filename Filename to write to. @param color Any character to retain colors, no colors if NULL From 9ea2c18b82c132444590d5309d54284be2735178 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 30 May 2023 16:01:52 +0200 Subject: [PATCH 018/128] Update gnuplot_i.h * Return type `void` throughout * Correction in `gnuplot_set_axislabel` --- gnuplot_i.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gnuplot_i.h b/gnuplot_i.h index 0eb7a6a..273ef90 100755 --- a/gnuplot_i.h +++ b/gnuplot_i.h @@ -28,9 +28,9 @@ #include #include -/** Maximal number of simultaneous temporary files */ +/** Maximum number of simultaneous temporary files */ #define GP_MAX_TMP_FILES 64 -/** Maximal size of a temporary file name */ +/** Maximum amount of characters of a temporary file name */ #define GP_TMP_NAME_SIZE 512 /*--------------------------------------------------------------------------- @@ -60,7 +60,7 @@ typedef struct _GNUPLOT_CTRL_ { } gnuplot_ctrl; /* - gnuplot_point: Simple point struct to allow return of points to the + gnuplot_point is a point struct to allow the return of points to the `gnuplot_plot_obj_xy` function by callback functions. */ @@ -85,18 +85,18 @@ void gnuplot_close (gnuplot_ctrl *handle); void gnuplot_cmd (gnuplot_ctrl *handle, char *cmd, ...); void gnuplot_setstyle (gnuplot_ctrl *handle, char *plot_style); void gnuplot_setterm (gnuplot_ctrl *handle, char *terminal); -void gnuplot_set_axislabel (gnuplot_ctrl *handle, char *label); +void gnuplot_set_axislabel (gnuplot_ctrl *handle, char *label, char *axis); void gnuplot_resetplot (gnuplot_ctrl *handle); /* gnplot plotting functions */ void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title); void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *title); -int gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char *title); -int gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols, char *title); -int gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, int nx, int ny, char *title); -int gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); -int gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); +void gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char *title); +void gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols, char *title); +void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, int nx, int ny, char *title); +void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); +void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, double *x, double *y, int n); void gnuplot_plot_slope (gnuplot_ctrl *handle, double a, double b, char *title); void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title); From 9de4d1b684b7839f15a7d2380d571a35fb3c87ba Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 30 May 2023 17:46:01 +0200 Subject: [PATCH 019/128] Add files via upload * Include informal favicon, for use in doxygen html-output --- images/favicon.ico | Bin 0 -> 4286 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 images/favicon.ico diff --git a/images/favicon.ico b/images/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c2489af66a63c44df208dbd57c94a81141aa55f6 GIT binary patch literal 4286 zcmc&$dr*{B6ki`XI%D8J5i<%}ErW_UPEA%eA%d(3A|av(nlF4!laFlDG&PGc(lW=U zk`igg2UIpZLBuY2y@@AG3H>S)E?Ip5=+$M1LV zIp=<>QuSiLVZ&5(RTU0Wse)80)o>OBZntdm@I*VJ@5pQj&qmn(i_q75Jr5Hsjd-@bh*H-^E$YUijo=Fc^eXR-ip* zJm+9NRD#-CGg4m_zOysx@Kx?XXe$j^Fwe;O%$*Hfxzfaa3knKABFA#aym-;b_Kjk= zke&Ul7rti=E*mnK<69=Yg0yj3jx%QT0p{0>`;vX{-u*D{g)>|i9`=zu?-`5UM~%$o zcF&F}lI@iFr#=i150`~}4vrqhIW)vAL2BY3h#2`CLPJBjNVa32&qTr`Koi>z^)udj zvQw)Q5g*ryDU)3oIYI;KJBqKwm+Q}+O40`pd~K_IIi`IPox^^MSRNd(WA9;{daZ(A8Z!7 zWs3oa!$1BJ(_U9G`E9`?4il;AAbh zjdI4pd;{3DLCmF116o>yA?=T^^+y?1m}u`V8tqJczWcUt-2O4=;9!kVTVAe&=Fe?y zz}z_kPuZi?pN6Y<&HdrW7$3ud&Mo-ebqV>VU6|Mw!1-i3B4Bd;26S`)Z?51R{(gXZB z#2VC`Lz?4B)Vpc{s|B|7G?9z9SBr$oUgANnza86!9o3COtPAJiWO1=q{oSC1vC(1# z661kM6YUuI#1O1?YB+}^`{U4e9mlz{LvT!Eg+?*gtp)6M0qnjK{-u3;g`U+5YEA>! zSn|t{0JCQB`5UYt{Po|~9FfC_5npnfPB@X{oWnUJ*!v^@(l(qgDgvgb2#i(B0ZP7m z)KpcWJ!7WO73`O$#l5u^wpnSgvNO#SzpShbB_(=xmbmyiF`$1ax1se^>#DKdIGuBt zbf+(NU;YsKl498DP-gq!V2$@H`xw>d?t(RI9-p(Zwbqm_%(H9qW^Hs*F-oMWa|CrXyvFQw9 z+a%+6-$3BKrcBOZvb`V9bg`VeTtL-HAp3o$+=ymYygzHTo^J9x@$l9EGp7su1N($2 zt)0YkkpIT!bj~5sJ^&ZHs=Ap->+CkEc=3lH8*Rp7)~a+y(zqACj@84Cj-{MKvON%u zF1>JK*N4TA*O>V^E(N+bz7AdNm+ch$K<5KLqaFeO#BulkFE@ev;geYh99ZK%ALcv4 zVRf}W^!j~$fBog3_E;M2xQ!)_F+3NmozeL5wCFiW?|Ju^|A)n=_%~hGknR}FIjp^w z%=f?(S9nx}r=o`ATo_%Zl41f4^{*g`+DgV;@gWSKkx`E@z+xp=L{Wo$f zPhVgC|8L+E&O0qBoI|>0D5`2s_~hUV|55U<-0D*dGo$Tk&LOwsEv1S-6Gvb8b#-+x znM|@s`>&j%=hD(rE}rw!JLz{F+lr{BUWjh$3;lJS98>ZyEG+ao|0TTt^G^T2BO@ab Q930#u5*8Ll`_QA~AE#7{G5`Po literal 0 HcmV?d00001 From 71ec68e4b2b55b7f592b9ff17971a1425f6bdb25 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 30 May 2023 17:46:57 +0200 Subject: [PATCH 020/128] Update README.md * Add introductory note --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da78422..b9127c9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,16 @@ gnuplot C interface library =========================== -This is a modification of the gnuplot_i library by Nicolas Devillard, which enables developers to create gnuplots from their C programs. It features the following enhancements: +Overview +-------- + +This is a modification of the `gnuplot_i` interface library by Nicolas Devillard, which enables developers to create [gnuplots](http://www.gnuplot.info/) from their C programs. + + +Enhancements +------------ + +It features the following enhancements: * 3D plots, using `gnuplot_splot(handle, x, y, z, n, "title")`. * Setting z-axis labels with `gnuplot_set_zlabel(handle, "z-axis label")`. From da22fe8a0e556a2d244b34a05f5b60b4a22f40d0 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 10:56:32 +0200 Subject: [PATCH 021/128] Update gnuplot_i.c * Update error messages * Update code comments --- gnuplot_i.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index f205b7d..5041bee 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -135,7 +135,7 @@ char *gnuplot_get_program_path (char *pname) { /* Try in all paths given in the PATH variable */ buf[0] = 0; path = getenv("PATH"); - FAIL_IF ((path != NULL), "PATH variable not set"); + FAIL_IF (path == NULL, "PATH variable not set, is gnuplot installed?"); for (i = 0; path[i]; ) { for (j = i; (path[j]) && (path[j] != ':'); j++); lg = j - i; @@ -282,7 +282,7 @@ void gnuplot_cmd (gnuplot_ctrl *handle, char *cmd, ...) { /** @brief Change the plotting style of a gnuplot session. @param handle Gnuplot session control handle - @param plot_style Plotting-style to use (character string) + @param plot_style Plotting-style (character string) @return void The provided plotting style is one of the following character strings: @@ -292,9 +292,9 @@ void gnuplot_cmd (gnuplot_ctrl *handle, char *cmd, ...) { - impulses - dots - steps - - errorbars + - errorbars (deprecated?) - boxes - - boxeserrorbars + - boxerrorbars */ /*--------------------------------------------------------------------------*/ @@ -324,11 +324,17 @@ void gnuplot_setstyle (gnuplot_ctrl *handle, char *plot_style) { @return void In gnuplot the terminal type is the output channel to which the plot should be - displayed on. This is typically 'x11' for Linux, 'acqua' for OSX or either - 'wxt' or 'windows' for MS-Windows. + displayed on. - No attempt is made to check the validity of the terminal name. This function - simply makes a note of it and calls `gnuplot_cmd` to change the name. + The provided terminal is one of the following character strings: + - `x11` for Linux, no anti-aliasing (default) + - `wxt` or `qt` for Linux, with anti-aliasing + - `aqua` for OSX + - `wxt` or `windows` for MS-Windows. + + No check is made on the validity of the terminal name. This function + calls `gnuplot_cmd` with the provided terminal name. If this function is not + called, then the `x11` terminal type will be used. */ /*--------------------------------------------------------------------------*/ @@ -828,9 +834,9 @@ void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void * } int main (int argc, char *argv[]) { - ... - gnuplot_plot_obj_xy(handle, points, PlotPoint, pCount, "Points"); - ... + ... + gnuplot_plot_obj_xy(handle, points, PlotPoint, pCount, "Points"); + ... } @endcode From a0f4b24b3b2764fd9cd64c2d2b1a94f1116b6cad Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 10:57:11 +0200 Subject: [PATCH 022/128] Update example.c * Updates based on testing --- examples/example.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/examples/example.c b/examples/example.c index 94b2e5a..535cc50 100644 --- a/examples/example.c +++ b/examples/example.c @@ -1,12 +1,14 @@ /* * Examples of gnuplot_i.c usage + * Compilation: gcc -Wall -g example.c gnuplot_i.c -o example + * */ #include #include #include "gnuplot_i.h" -#define SLEEP_LGTH 2 +#define SECONDS 1 #define NPOINTS 50 int main(int argc, char *argv[]) { @@ -18,20 +20,20 @@ int main(int argc, char *argv[]) { printf("*** Example of gnuplot control through C ***\n"); h1 = gnuplot_init(); - + gnuplot_setterm(h1 , "wxt"); /** Slopes */ gnuplot_setstyle(h1, "lines"); printf("*** plotting slopes\n"); printf("y = x\n"); gnuplot_plot_slope(h1, 1.0, 0.0, "unity slope"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("y = 2*x\n"); gnuplot_plot_slope(h1, 2.0, 0.0, "y=2x"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("y = -x\n"); gnuplot_plot_slope(h1, -1.0, 0.0, "y=-x"); - sleep(SLEEP_LGTH); + sleep(SECONDS); /** Equations */ @@ -40,13 +42,13 @@ int main(int argc, char *argv[]) { printf("*** various equations\n"); printf("y = sin(x)\n"); gnuplot_plot_equation(h1, "sin(x)", "sine"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("y = log(x)\n"); gnuplot_plot_equation(h1, "log(x)", "logarithm"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("y = sin(x)*cos(2*x)\n"); gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product"); - sleep(SLEEP_LGTH); + sleep(SECONDS); /** Styles */ @@ -56,15 +58,15 @@ int main(int argc, char *argv[]) { printf("sine in points\n"); gnuplot_setstyle(h1, "points"); gnuplot_plot_equation(h1, "sin(x)", "sine"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("sine in impulses\n"); gnuplot_setstyle(h1, "impulses"); gnuplot_plot_equation(h1, "sin(x)", "sine"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("sine in steps\n"); gnuplot_setstyle(h1, "steps"); gnuplot_plot_equation(h1, "sin(x)", "sine"); - sleep(SLEEP_LGTH); + sleep(SECONDS); /** User defined 1d and 2d point sets */ @@ -76,7 +78,7 @@ int main(int argc, char *argv[]) { x[i] = (double)i * i; } gnuplot_plot_x(h1, x, NPOINTS, "user-defined doubles"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("*** user-defined lists of points\n"); for (i = 0; i < NPOINTS; i++) { x[i] = (double)i; @@ -85,7 +87,7 @@ int main(int argc, char *argv[]) { gnuplot_resetplot(h1); gnuplot_setstyle(h1, "points"); gnuplot_plot_xy(h1, x, y, NPOINTS, "user-defined points"); - sleep(SLEEP_LGTH); + sleep(SECONDS); /** Multiple output screens */ @@ -101,21 +103,21 @@ int main(int argc, char *argv[]) { gnuplot_setstyle(h4, "lines"); printf("window 1: sin(x)\n"); gnuplot_plot_equation(h1, "sin(x)", "sin(x)"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("window 2: x*sin(x)\n"); gnuplot_plot_equation(h2, "x*sin(x)", "x*sin(x)"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("window 3: log(x)/x\n"); gnuplot_plot_equation(h3, "log(x)/x", "log(x)/x"); - sleep(SLEEP_LGTH); + sleep(SECONDS); printf("window 4: sin(x)/x\n"); gnuplot_plot_equation(h4, "sin(x)/x", "sin(x)/x"); - sleep(SLEEP_LGTH); + sleep(SECONDS); /** Close gnuplot handles */ printf("\n\n"); - printf("*** end of gnuplot example\n"); + printf("*** closing all gnuplot windows\n"); gnuplot_close(h1); gnuplot_close(h2); gnuplot_close(h3); From 70841b98fc4c5a1e6d1052c4ee73a820699f706f Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 11:09:48 +0200 Subject: [PATCH 023/128] Add files via upload Add original documentation as provided by Nicolas Devillard. Some stylistic updates and corrections have been applied. --- gnuplot_i.txt | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 gnuplot_i.txt diff --git a/gnuplot_i.txt b/gnuplot_i.txt new file mode 100644 index 0000000..1e8a867 --- /dev/null +++ b/gnuplot_i.txt @@ -0,0 +1,146 @@ + +gnuplot_i: a short documentation +-------------------------------- + +gnuplot_i (formerly known as gnuplot_pipes) provides a programmer-friendly +set of routines to use gnuplot as a data displayer from a C program. + +The procedure to display graphics in a gnuplot session is: + +1. Open a new gnuplot session, referenced by a handle of type (pointer to) + gnuplot_ctrl. This is done by calling gnuplot_init(): + + gnuplot_ctrl * h ; + h = gnuplot_init() ; + + h will be used as the handle to the gnuplot session which was just opened, + by all further functions. + + +2. Send optionally display configuration orders. The following functions + are available: + + gnuplot_setstyle (handle, style) + sets the plotting style of the next plots + + gnuplot_set_xlabel (handle, label) + sets the X label for the next plots + + gnuplot_set_ylabel (handle, label) + sets the Y label for the next plots + + Examples: + + gnuplot_setstyle (h, "impulses"); + gnuplot_set_axislabel (h, "my X label", 'x'); + gnuplot_set_axislabel (h, "my Y label", 'y'); + + The most critical routine is gnuplot_cmd(), which sends character strings + to gnuplot as though they were typed in by a user. This routine works in a + printf fashion, accepting the same kind of format string and variable number + of arguments. + + The prototype is: + + gnuplot_cmd(handle, command, ...) + + Example: + + char myfile[] = "/data/file_in.dat"; + + gnuplot_cmd(handle, "plot '%s'", myfile); + for (int i = 0; i < 10; i++) { + gnuplot_cmd (handle, "plot y=%d*x", i); + } + + The following commands request the output to be done to a Postscript file + named 'curve.ps': + + gnuplot_cmd(h, "set terminal postscript") ; + gnuplot_cmd(h, "set output \"curve.ps\"") ; + + With gnuplot_cmd() it should be easy to add up some more configuration + related functions where needed. + + +3. Send some display orders: either functions or doubles, or double points. + The following functions are available: + + gnuplot_plot_slope() + to display a slope + + gnuplot_plot_equation() + to display an equation + + gnuplot_plot_1d_var1() + to display user-defined 1d data with a single variable. + Input is a list of values, assumed regularly spaced on the + X-axis. + + gnuplot_plot_1d_var2() + to display user-defined 1d data with two variables. + Input is a list of point coordinates. The 'dpoint' struct + type is provided for that purpose. + + gnuplot_resetplot() + states that the current gnuplot display will be cleared + before next display is done. + + +4. Close the gnuplot handle. This is important, since otherwise not all + temporary files will be cleaned for /tmp and /var/tmp. + + gnuplot_close(h) ; + + +See example of gnuplot_i use in the provided file 'example.c'. + + +Some more points before you start using gnuplot_i +------------------------------------------------- + + Notice that it is possible to open several gnuplot sessions from the same + program. Just be careful to which session you are talking to when using + functions. Example: + + h1 = gnuplot_init() ; + h2 = gnuplot_init() ; + + gnuplot_plot_equation(h1, "sin(x)", "sine on first session"); + gnuplot_plot_equation(h2, "log(x)", "log on second session") ; + sleep(3) ; + gnuplot_close(h1) ; + gnuplot_close(h2) ; + + Never forget to close opened sessions! This would leave temporary files. + Normally your temporary directories should be cleaned automatically so every + now and then, but best is to close all windows prior to closing the session. + + User interactions are not part of gnuplot_i. Feel free to use your own. + + No timing mechanisms are provided to leave the outputs on screen + until e.g. a key is pressed. I leave it up to gnuplot_i users to provide + that kind of functionality in their own application, depending on the + kind of interaction they need. + + gnuplot_i is completely free software. Use it for whatever you want to do + with it without any fee, and do not hesitate to send feedback to me: + + + + If you can, I would appreciate a mention somewhere that you are using + 'gnuplot_i' in your application. Something like: + + "This software uses the gnuplot_i library written by + N.Devillard ." + + If you are using gnuplot_i for a web-based application, you can also add + a link to the gnuplot home page: + + http://ndevilla.free.fr/ + + If you are so happy about this piece of code that you would like + to fund more stuff like that, do not hesitate to send me cash :-) + + +Nicolas Devillard -- April 2000 From 347f02d95b242775dbb7e7741e66248aac8c853e Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 11:12:51 +0200 Subject: [PATCH 024/128] Update sinepng.c * Updates after testing --- examples/sinepng.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/sinepng.c b/examples/sinepng.c index 39f50cd..7b992a2 100644 --- a/examples/sinepng.c +++ b/examples/sinepng.c @@ -1,3 +1,11 @@ +/* + * Examples of gnuplot_i.c usage + * Compilation: gcc -Wall -g sinepng.c gnuplot_i.c -o sinepng + * + * This program produces a file sine.png in the same location as the executable + * + */ + #include #include #include From f711928b01e78d93dcf2eaa334dbd7954179e9d2 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 11:25:23 +0200 Subject: [PATCH 025/128] Update animation.c * Updates based on testing --- examples/animation.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/animation.c b/examples/animation.c index 033a36b..14e415c 100644 --- a/examples/animation.c +++ b/examples/animation.c @@ -1,3 +1,10 @@ +/* + * Examples of gnuplot_i.c usage + * Compilation: gcc -Wall -g animation.c gnuplot_i.c -o animation + * + * This program produces an animated sine wave in a gnuplot window + */ + #include #include #include "gnuplot_i.h" @@ -14,7 +21,7 @@ int main(int argc, char *argv[]) { gnuplot_cmd(handle, "plot sin(x+%g)", phase); } - for (phase = 10; phase> = 0.1; phase -= 0.1) { + for (phase = 10; phase >= 0.1; phase -= 0.1) { gnuplot_resetplot(handle); gnuplot_cmd(handle, "plot sin(x+%g)", phase); } From 14c82da7bae74b2855c1f49df106a6cad3b6f117 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 11:37:39 +0200 Subject: [PATCH 026/128] Create TODO Init --- TODO | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..a3c5606 --- /dev/null +++ b/TODO @@ -0,0 +1,7 @@ +* More unit tests to be added as not all functions are being covered by tests, notably 3D plots, such as contourplots and heatmaps. +* Plotting styles have been added to gnuplot since this interface library was completed, hence further testing and documentation on this. +* More field testing is needed: + - Does the current version still work on Windows / OS-X / other operating systems? + - How does it perform in high-volume or high-performance environments? + - Are there limitations which need to be looked at, for example the maximum amount of open gnuplot files? +* The file gnuplot_i.txt can probably be marked down. From c75eafbe76a05954b500d370ee11ce18055b9a91 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 12:03:55 +0200 Subject: [PATCH 027/128] Update README.md * Added list of examples * Confirmed public domain * Stylistic improvements --- README.md | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b9127c9..e78a786 100644 --- a/README.md +++ b/README.md @@ -4,43 +4,60 @@ gnuplot C interface library Overview -------- -This is a modification of the `gnuplot_i` interface library by Nicolas Devillard, which enables developers to create [gnuplots](http://www.gnuplot.info/) from their C programs. +The `gnuplot_i` interface library enables developers to create [gnuplots](http://www.gnuplot.info/) from their C programs. +It was originally developed by Nicolas Devillard (2000) who also placed it in the public domain. + +Numerous authors have contributed to this package, among which Peter Maresh to compile and run on MS-Windows 7/64 using mingw64. + +The library was since enhanced by Robert Bradley (2004-2006). Enhancements ------------ -It features the following enhancements: +This interface library features the following enhancements: * 3D plots, using `gnuplot_splot(handle, x, y, z, n, "title")`. -* Setting z-axis labels with `gnuplot_set_zlabel(handle, "z-axis label")`. -* Production of colour PostScript files with `gnuplot_hardcopy_colour(handle, "graph.ps")`. +* Setting z-axis labels with `gnuplot_set_axislabel(handle, "z-axis label", "z")`. +* Production of colour PostScript files with `gnuplot_hardcopy(handle, "graph.ps")`. * Windows support. -* On OS X, if DISPLAY environment variable is not set, or USE_AQUA=1, then aqua is used instead of x11. +* On OS X, if DISPLAY environment variable is not set or USE_AQUA=1, then aqua is used instead of x11. * Plotting of complex structures through the use of callbacks, see `gnuplot_plot_obj_xy` and `gnuplot_splot_obj`. * Contour plotting with `gnuplot_setstyle(handle, "lines")` and `gnuplot_contour_plot(handle, x, y, z, nx, ny, "title")`. If you have any questions or comments, these can be sent to robert.bradley@merton.oxon.org, or via my website (http://www.robert-bradley.co.uk). +Examples +-------- + +This library comes with the following examples: + +* example.c: a garden variety of `gnuplot_i` function calls to demonstrate general usage and capabilities. +* animation.c: a brief animation of a run-time generated sine wave. +* sinepng.c: a demonstration of how `gnuplot_i` can be used to store its output as a file. + +Compilation instructions are included in each of these examples. + + Changelog --------- -29 May 2023 - Refactoring, stylistic improvements +29 May 2023 - Refactoring, stylistic improvements, documentation updates. -02 Apr 2006 - Added gnuplot_splot_grid for plotting 2D arrays of data, and restored the lost contour plotting code. +02 Apr 2006 - Added `gnuplot_splot_grid` for plotting 2D arrays of data, and restored the lost contour plotting code. 13 Mar 2006 - Fixed "bus error" under OS X when not using X11 and USE_AQUA environment variable is not set. -23 Nov 2005 - gnuplot_contour_plot added (plots contours, use gnuplot_setstyle to set the contour style) +23 Nov 2005 - Added `gnuplot_contour_plot`, which plots contours; use `gnuplot_setstyle` to set the contour style -15 Sep 2005 - Added possible OS X support, plus the gnuplot_plot_obj_xy and gnuplot_splot_obj functions. +15 Sep 2005 - Added possible OS X support, plus the `gnuplot_plot_obj_xy` and `gnuplot_splot_obj` functions. -11 Sep 2005 - Windows support added +11 Sep 2005 - Added Windows support 14 Aug 2005 - Included fixes from the official version 2.10 -02 Nov 2004 - Initial version uploaded (based on gnuplot_i v2.6) +02 Nov 2004 - Initial version uploaded, based on gnuplot_i v2.6 Documentation From 6718b0fc2eacacabe16e969d84f20d01a835e7fc Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 12:05:50 +0200 Subject: [PATCH 028/128] Update TODO * Added opportunity of refactoring --- TODO | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO b/TODO index a3c5606..26282f2 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,5 @@ * More unit tests to be added as not all functions are being covered by tests, notably 3D plots, such as contourplots and heatmaps. +* Further refactoring. * Plotting styles have been added to gnuplot since this interface library was completed, hence further testing and documentation on this. * More field testing is needed: - Does the current version still work on Windows / OS-X / other operating systems? From 611b5dbe9ae52a8852b2e3ffb1a526caac0a3901 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 12:07:20 +0200 Subject: [PATCH 029/128] Update gnuplot_i.txt *Stylistic improvements --- gnuplot_i.txt | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gnuplot_i.txt b/gnuplot_i.txt index 1e8a867..d6176e5 100644 --- a/gnuplot_i.txt +++ b/gnuplot_i.txt @@ -5,13 +5,15 @@ gnuplot_i: a short documentation gnuplot_i (formerly known as gnuplot_pipes) provides a programmer-friendly set of routines to use gnuplot as a data displayer from a C program. +Gnuplot must be installed to use this package. + The procedure to display graphics in a gnuplot session is: 1. Open a new gnuplot session, referenced by a handle of type (pointer to) gnuplot_ctrl. This is done by calling gnuplot_init(): - gnuplot_ctrl * h ; - h = gnuplot_init() ; + gnuplot_ctrl * h; + h = gnuplot_init(); h will be used as the handle to the gnuplot session which was just opened, by all further functions. @@ -56,8 +58,8 @@ The procedure to display graphics in a gnuplot session is: The following commands request the output to be done to a Postscript file named 'curve.ps': - gnuplot_cmd(h, "set terminal postscript") ; - gnuplot_cmd(h, "set output \"curve.ps\"") ; + gnuplot_cmd(h, "set terminal postscript"); + gnuplot_cmd(h, "set output \"curve.ps\""); With gnuplot_cmd() it should be easy to add up some more configuration related functions where needed. @@ -90,7 +92,7 @@ The procedure to display graphics in a gnuplot session is: 4. Close the gnuplot handle. This is important, since otherwise not all temporary files will be cleaned for /tmp and /var/tmp. - gnuplot_close(h) ; + gnuplot_close(h); See example of gnuplot_i use in the provided file 'example.c'. @@ -100,17 +102,17 @@ Some more points before you start using gnuplot_i ------------------------------------------------- Notice that it is possible to open several gnuplot sessions from the same - program. Just be careful to which session you are talking to when using + program. Just be careful as to which session you are talking to when using functions. Example: - h1 = gnuplot_init() ; - h2 = gnuplot_init() ; + h1 = gnuplot_init(); + h2 = gnuplot_init(); gnuplot_plot_equation(h1, "sin(x)", "sine on first session"); - gnuplot_plot_equation(h2, "log(x)", "log on second session") ; - sleep(3) ; - gnuplot_close(h1) ; - gnuplot_close(h2) ; + gnuplot_plot_equation(h2, "log(x)", "log on second session"); + sleep(3); + gnuplot_close(h1); + gnuplot_close(h2); Never forget to close opened sessions! This would leave temporary files. Normally your temporary directories should be cleaned automatically so every From 320b30e4573e218c907b65dd8777ae1c9f3e7d8c Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 12:09:17 +0200 Subject: [PATCH 030/128] Update gnuplot_i.c * Code comment updates * Vim instructions, copied from original --- gnuplot_i.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index 5041bee..34095a7 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -489,7 +489,7 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t char name[128]; char cmd[GP_CMD_SIZE]; - /* Trap errors on mandatory arguments */ + /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || x == NULL || y == NULL || (n < 1), "One of the parameters has been misspecified"); FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); @@ -561,7 +561,7 @@ void gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n char name[128]; char cmd[GP_CMD_SIZE]; - /* Trap errors on mandatory arguments */ + /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || x == NULL || y == NULL || (n < 1), "One of the parameters has been misspecified"); FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); @@ -620,7 +620,7 @@ void gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int col char name[128]; char cmd[GP_CMD_SIZE]; - /* Trap errors on mandatory arguments */ + /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || points == NULL || (rows < 1) || (cols < 1), "One of the parameters has been misspecified"); FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); @@ -701,7 +701,7 @@ void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z char name[128]; char cmd[GP_CMD_SIZE]; - /* Trap errors on mandatory arguments */ + /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || x == NULL || y == NULL || (nx < 1) || (ny < 1), "One of the parameters has been misspecified"); FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); @@ -768,7 +768,7 @@ void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void * char name[128]; char cmd[GP_CMD_SIZE]; - /* Trap errors on mandatory arguments */ + /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || getPoint == NULL || (n < 1), "One of the parameters has been misspecified"); FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); @@ -855,7 +855,7 @@ void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void char name[128]; char cmd[GP_CMD_SIZE]; - /* Trap errors on mandatory arguments */ + /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || getPoint == NULL || (n < 1), "One of the parameters has been misspecified"); FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); @@ -911,7 +911,7 @@ void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void /*--------------------------------------------------------------------------*/ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, double *x, double *y, int n) { - /* Define handle as local variable to isolate itfrom other gnuplot sessions */ + /* Define handle as local variable to isolate it from other gnuplot sessions */ gnuplot_ctrl *handle; /* Some error trapping */ @@ -1045,3 +1045,5 @@ void gnuplot_hardcopy (gnuplot_ctrl *handle, char *filename, char *color) { } #endif + +/* vim: set ts=4 et sw=4 tw=75 */ From 04e92ab32ab9286ccc22379d0f4e07a481804d8b Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 12:21:04 +0200 Subject: [PATCH 031/128] Update gnuplot_i.h * Code comment updates: doxygen --- gnuplot_i.h | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/gnuplot_i.h b/gnuplot_i.h index 273ef90..636515e 100755 --- a/gnuplot_i.h +++ b/gnuplot_i.h @@ -38,8 +38,14 @@ ---------------------------------------------------------------------------*/ /** - @typedef gnuplot_ctrl - @brief gnuplot session handle. + @typedef gnuplot_ctrl + @brief gnuplot session handle. + @param gnucmd Pipe to gnuplot process. + @param nplots Number of currently active plots. + @param pstyle Current plotting style. + @param term Save terminal name (used by hardcopy functions). + @param to_delete Name of temporary files. + @param ntmp Number of temporary files. This structure holds all necessary information to talk to a gnuplot session. It is built and returned by gnuplot_init() and later used by all functions @@ -51,15 +57,21 @@ */ typedef struct _GNUPLOT_CTRL_ { - FILE *gnucmd; /* Pipe to gnuplot process */ - int nplots; /* Number of currently active plots */ - char pstyle[32]; /* Current plotting style */ - char term[32]; /* Save terminal name (used by hardcopy functions) */ - char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE]; /* Name of temporary files */ - int ntmp; /* Number of temporary files */ + FILE *gnucmd; + int nplots; + char pstyle[32]; + char term[32]; + char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE]; + int ntmp; } gnuplot_ctrl; -/* +/** + @typedef gnuplot_point + @param x X-coodinate (double). + @param y Y-coodinate (double). + @param z Z-coodinate (double). + @brief gnuplot point structure, ie set of [x,y,z] coordinates. + gnuplot_point is a point struct to allow the return of points to the `gnuplot_plot_obj_xy` function by callback functions. */ From e6ac6ed09d0a6c8ae2cfada4392145b53f0125c6 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Wed, 31 May 2023 15:27:04 +0200 Subject: [PATCH 032/128] Update TODO * Add opportunity for unit test --- TODO | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 26282f2..b3c66e2 100644 --- a/TODO +++ b/TODO @@ -4,5 +4,6 @@ * More field testing is needed: - Does the current version still work on Windows / OS-X / other operating systems? - How does it perform in high-volume or high-performance environments? - - Are there limitations which need to be looked at, for example the maximum amount of open gnuplot files? + - Are there limitations which need to be looked at, for example the maximum amount of open gnuplot files (GP_MAX_TMP_FILES)? + - Does it still work if gnuplot is installed but qt or wxWidgets is not? * The file gnuplot_i.txt can probably be marked down. From 57a61b1375f44f35e53f56101f31adc1d0dacc40 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Fri, 30 Jun 2023 10:02:50 +0200 Subject: [PATCH 033/128] Update gnuplot_i.c * Refactoring --- gnuplot_i.c | 84 ++++++++++++++++++----------------------------------- 1 file changed, 28 insertions(+), 56 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index 34095a7..8f3643b 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -32,21 +32,21 @@ Defines ---------------------------------------------------------------------------*/ -/** Maximum amount of characters of a gnuplot command */ +/** Maximum amount of characters of a gnuplot command. */ #define GP_CMD_SIZE 2048 -/** Maximum amount of characters of a plot title */ +/** Maximum amount of characters of a plot title. */ #define GP_TITLE_SIZE 80 -/** Maximum amount of characters for an equation */ +/** Maximum amount of characters for an equation y=f(x). */ #define GP_EQ_SIZE 512 -/** Maximum amount of characters of a name in the PATH */ +/** Maximum amount of characters of a name in the PATH. */ #define PATH_MAXNAMESZ 4096 -/** Error message display */ +/** Error message display. */ #define FAIL_IF(EXP, MSG) ({ if (EXP) { printf("ERROR: " MSG "\n"); exit(EXIT_FAILURE); }}) #ifdef _WIN32 #undef P_tmpdir #endif -/** Define P_tmpdir if not defined; this is normally a POSIX symbol */ +/** Define `P_tmpdir` if not defined; this is normally a POSIX symbol. */ #ifndef P_tmpdir #define P_tmpdir "." #endif @@ -216,7 +216,7 @@ gnuplot_ctrl *gnuplot_init (void) { /*-------------------------------------------------------------------------*/ /** @brief Closes a gnuplot session previously opened by gnuplot_init() - @param handle Gnuplot session control handle. + @param handle Gnuplot session control handle. @return void Kills the child process-ID (PID) and deletes all opened temporary files. @@ -245,8 +245,8 @@ void gnuplot_close (gnuplot_ctrl *handle) { /*-------------------------------------------------------------------------*/ /** @brief Sends a command to an active gnuplot session. - @param handle Gnuplot session control handle - @param cmd Command to send, same as a printf statement. + @param handle Gnuplot session control handle + @param cmd Command to send, same as a printf statement. This sends a string to an active gnuplot session, to be executed. There is no way to know if the command has been successfully executed or not. @@ -352,7 +352,7 @@ void gnuplot_setterm (gnuplot_ctrl *handle, char *terminal) { @brief Sets the axis label of a gnuplot session. @param handle Gnuplot session control handle. @param label Character string to use for axis label. - @param axis Character string to to identify axis, ie 'x', 'y' or 'z'. + @param axis Character string to identify axis, ie "x", "y" or "z". @return void Sets the axis label for a gnuplot session. @@ -422,7 +422,7 @@ void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title) { /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || x == NULL || (n < 1), "One of the parameters has been misspecified"); - FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by another process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ @@ -441,11 +441,7 @@ void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title) { close(tmpfd); /* Command to be sent to gnuplot */ - if (title == NULL) { - sprintf(cmd, "%s \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, handle->pstyle); - } else { - sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, title, handle->pstyle); - } + sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, (title) ? title : "No title" , handle->pstyle); /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); @@ -491,7 +487,7 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || x == NULL || y == NULL || (n < 1), "One of the parameters has been misspecified"); - FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by another process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ @@ -510,11 +506,7 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t close(tmpfd); /* Command to be sent to gnuplot */ - if (title == NULL) { - sprintf(cmd, "%s \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, handle->pstyle); - } else { - sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, title, handle->pstyle); - } + sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, (title) ? title : "No title" , handle->pstyle); /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); @@ -563,7 +555,7 @@ void gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || x == NULL || y == NULL || (n < 1), "One of the parameters has been misspecified"); - FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by another process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ @@ -582,11 +574,7 @@ void gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n close(tmpfd); /* Command to be sent to gnuplot */ - if (title == NULL) { - sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); - } else { - sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); - } + sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, (title) ? title : "No title", handle->pstyle); /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); @@ -622,7 +610,7 @@ void gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int col /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || points == NULL || (rows < 1) || (cols < 1), "One of the parameters has been misspecified"); - FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by another process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ @@ -645,11 +633,7 @@ void gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int col close(tmpfd); /* Command to be sent to gnuplot */ - if (title == NULL) { - sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); - } else { - sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); - } + sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, (title) ? title : "No title", handle->pstyle); /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); @@ -703,7 +687,7 @@ void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || x == NULL || y == NULL || (nx < 1) || (ny < 1), "One of the parameters has been misspecified"); - FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by another process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ @@ -731,11 +715,8 @@ void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z gnuplot_cmd(handle, "set view map"); gnuplot_cmd(handle, "set view 0,0"); - if (title == NULL) { - sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); - } else { - sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); - } + /* Command to be sent to gnuplot */ + sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, (title) ? title : "No title", handle->pstyle); /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); @@ -770,7 +751,7 @@ void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void * /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || getPoint == NULL || (n < 1), "One of the parameters has been misspecified"); - FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by another process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ @@ -791,11 +772,7 @@ void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void * close(tmpfd); /* Command to be sent to gnuplot */ - if (title == NULL) { - sprintf(cmd, "splot \"%s\" with %s", name, handle->pstyle); - } else { - sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, title, handle->pstyle); - } + sprintf(cmd, "splot \"%s\" title \"%s\" with %s", name, (title) ? title : "No title", handle->pstyle); /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); @@ -840,7 +817,7 @@ void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void * } @endcode - Alternatively, PlotPoint could return values based on a complex formula and + Alternatively, `PlotPoint` could return values based on a complex formula and many sources of information. For example, it could be used to perform a Discrete Fourier Transform on an array of complex numbers, calculating one transformed point per call. @@ -857,7 +834,7 @@ void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void /* Error handling: mandatory arguments, already open session, opening temporary file */ FAIL_IF (handle == NULL || getPoint == NULL || (n < 1), "One of the parameters has been misspecified"); - FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by aother process"); + FAIL_IF (handle->nplots > 0, "A gnuplot session is already open and held by another process"); FAIL_IF (handle->ntmp == GP_MAX_TMP_FILES - 1, "Maximum number of temporary files reached: cannot open more"); /* Open temporary file for output */ @@ -878,11 +855,7 @@ void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void close(tmpfd); /* Command to be sent to gnuplot */ - if (title == NULL) { - sprintf(cmd, "%s \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, handle->pstyle); - } else { - sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, title, handle->pstyle); - } + sprintf(cmd, "%s \"%s\" title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", name, (title) ? title : "No title", handle->pstyle); /* Send command to gnuplot */ gnuplot_cmd(handle, cmd); @@ -940,7 +913,6 @@ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, @param b Intercept. @param title Title of the plot (can be NULL). @return void - @doc Plot a slope on a gnuplot session. The general form of the equation is y=ax+b, where only the slope a and intercept b are provided. @@ -999,8 +971,8 @@ void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title) { char plot_str[GP_EQ_SIZE]; char title_str[GP_TITLE_SIZE]; - strcpy(title_str, (title == NULL) ? "no title" : title); strcpy(plot_str, (handle->nplots > 0) ? "replot" : "plot"); + strcpy(title_str, (title == NULL) ? "no title" : title); sprintf(cmd, "%s %s title \"%s\" with %s", plot_str, equation, title_str, handle->pstyle); gnuplot_cmd(handle, cmd); handle->nplots++; @@ -1027,7 +999,7 @@ void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title) { h = gnuplot_init(); strcpy(eq, "sin(x) * cos(2*x)"); gnuplot_plot_equation(h, eq, "Sine wave", normal); - gnuplot_hardcopy(h, "sinewave.ps"); + gnuplot_hardcopy(h, "sinewave.ps", "color"); gnuplot_close(h); @endcode */ From 60c59c1eb737a7006758b14873c0750fc8eab8b9 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sat, 1 Jul 2023 00:19:57 +0200 Subject: [PATCH 034/128] Update gnuplot_i.c * Refactoring * Codespell issues --- gnuplot_i.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index 8f3643b..1ad9563 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -933,10 +933,8 @@ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, void gnuplot_plot_slope (gnuplot_ctrl *handle, double a, double b, char *title) { char cmd[GP_CMD_SIZE]; - char title_str[GP_TITLE_SIZE]; - strcpy(title_str, (title == NULL) ? "no title" : title); - sprintf(cmd, "%s %g * x + %g title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", a, b, title_str, handle->pstyle); + sprintf(cmd, "%s %g * x + %g title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", a, b, (title) ? title : "No title", handle->pstyle); gnuplot_cmd(handle, cmd); handle->nplots++; } From 052afe90c34141acce59d712cab59d2298632282 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sat, 15 Jul 2023 14:01:51 +0200 Subject: [PATCH 035/128] Update gnuplot_i.c * Add print_gnuplot_handle function * Update documentation * Add plot dimensions as parameters * Refactoring --- gnuplot_i.c | 75 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index 1ad9563..cb6e25b 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -70,7 +70,7 @@ /** @brief Create temporary output pipe with randomised name. @param name Name of the pipe. - @return int + @return int */ /*-------------------------------------------------------------------------*/ @@ -183,9 +183,9 @@ gnuplot_ctrl *gnuplot_init (void) { #endif #endif #ifndef _WIN32 - FAIL_IF (gnuplot_get_program_path("gnuplot") == NULL, "Cannot find gnuplot in your PATH"); + FAIL_IF (gnuplot_get_program_path("gnuplot") == NULL, "Cannot find gnuplot in your PATH, check `which gnuplot`"); #endif - FAIL_IF (gnuplot_get_program_path(GNUPLOT_EXEC) == NULL, "Cannot find gnuplot in your PATH"); + FAIL_IF (gnuplot_get_program_path(GNUPLOT_EXEC) == NULL, "Cannot find gnuplot in your PATH, check `which gnuplot`"); /* Structure initialization: */ handle = (gnuplot_ctrl *)malloc(sizeof(gnuplot_ctrl)); @@ -198,21 +198,46 @@ gnuplot_ctrl *gnuplot_init (void) { FAIL_IF (0 == 0, "Error starting gnuplot"); } + /* Set plot dimensions (should be handled elsewhere, but just to get things going) */ + int width = 900; + int height = 400; + /* Set terminal output type */ #ifdef _WIN32 - gnuplot_setterm(handle, "windows"); + gnuplot_setterm(handle, "windows", width, height); #elif __APPLE__ - /* Determine whether we should use aqua or x11 as our default */ + /* Determine whether to use aqua or x11 as the default */ if (getenv("DISPLAY") == NULL || (getenv("USE_AQUA") != NULL && strcmp(getenv("USE_AQUA"), "1") >= 0)) - gnuplot_setterm(handle, "aqua"); + gnuplot_setterm(handle, "aqua", width, height); else - gnuplot_setterm(handle, "x11"); + gnuplot_setterm(handle, "x11", width, height); #else - gnuplot_setterm(handle, "x11"); + /* The default is wxt, but this requires wxWidgets to be installed (need a test for that) */ + gnuplot_setterm(handle, "wxt", width, height); #endif return handle; } +/*-------------------------------------------------------------------------*/ +/** + @brief Print contents of gnuplot control hande to screen. + @param handle Gnuplot session control handle + + This is for debugging purposes only. + + */ +/*--------------------------------------------------------------------------*/ + +void print_gnuplot_handle (gnuplot_ctrl *handle) { + //fprintf(gnucmd); /*!< Pipe to gnuplot process. */ + printf("Temporary files: %d\n", handle->ntmp); /*!< Number of temporary files in the current session. */ + printf("Active plots: %d\n", handle->nplots); /*!< Number of currently active plots. */ + printf("Plotting style: %s\n", handle->pstyle); /*!< Current plotting style. */ + printf("Terminal name: %s\n", handle->term); /*!< Save terminal name (used by `gnuplot_hardcopy()` function). */ + //char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE]; /*!< Names of temporary files. Only relevant for multiplots */ + return; +} + /*-------------------------------------------------------------------------*/ /** @brief Closes a gnuplot session previously opened by gnuplot_init() @@ -308,7 +333,7 @@ void gnuplot_setstyle (gnuplot_ctrl *handle, char *plot_style) { strcmp(plot_style, "errorbars") && strcmp(plot_style, "boxes") && strcmp(plot_style, "boxerrorbars")) { - fprintf(stderr, "Warning: unknown requested style: using 'points'\n"); + fprintf(stderr, "Warning: unknown requested plot style: using default 'points'\n"); strcpy(handle->pstyle, "points"); } else { strcpy(handle->pstyle, plot_style); @@ -326,7 +351,7 @@ void gnuplot_setstyle (gnuplot_ctrl *handle, char *plot_style) { In gnuplot the terminal type is the output channel to which the plot should be displayed on. - The provided terminal is one of the following character strings: + The terminal type should be one of the following character strings: - `x11` for Linux, no anti-aliasing (default) - `wxt` or `qt` for Linux, with anti-aliasing - `aqua` for OSX @@ -338,12 +363,14 @@ void gnuplot_setstyle (gnuplot_ctrl *handle, char *plot_style) { */ /*--------------------------------------------------------------------------*/ -void gnuplot_setterm (gnuplot_ctrl *handle, char *terminal) { +void gnuplot_setterm (gnuplot_ctrl *handle, char *terminal, int width, int height) { char cmd[64]; strncpy(handle->term, terminal, 32); handle->term[31] = 0; - sprintf(cmd, "set terminal %s", handle->term); + FAIL_IF (width < 0 || height < 0, "Plot size dimensions cannot be negative"); + sprintf(cmd, "set terminal %s size %d,%d", handle->term, width, height); + //printf("set terminal %s size %d,%d", handle->term, width, height); gnuplot_cmd(handle, cmd); } @@ -356,6 +383,12 @@ void gnuplot_setterm (gnuplot_ctrl *handle, char *terminal) { @return void Sets the axis label for a gnuplot session. + + Example: + + @code + gnuplot_set_axislabel(h, "Time(sec)", "x"); + @endcode */ /*--------------------------------------------------------------------------*/ @@ -733,7 +766,7 @@ void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z @param title Title of the plot (can be NULL). @return void - Calback: + Callback: void getPoint(void *object, gnuplot_point *point, int index, int pointCount); @param obj Pointer to an arbitrary object @@ -878,8 +911,8 @@ void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void or XY signal depending on a provided y, waits for a carriage return on stdin and closes the session. - An empty title, empty style, or empty labels for X and Y may be provided. - Default valuess are provided in this case. + An empty title, empty style, or empty labels for X and Y may be provided. + Default values are provided in this case. */ /*--------------------------------------------------------------------------*/ @@ -887,9 +920,9 @@ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, /* Define handle as local variable to isolate it from other gnuplot sessions */ gnuplot_ctrl *handle; - /* Some error trapping */ - if (x == NULL || n < 1) return; - if ((handle = gnuplot_init()) == NULL) return; + /* Some error handling */ + FAIL_IF (x == NULL || n < 1, "One of the parameters has been misspecified"); + FAIL_IF ((handle = gnuplot_init()) == NULL, "Cannot initialize gnuplot handle"); /* Generate commands to send to gnuplot */ gnuplot_setstyle(handle, (style == NULL) ? "lines" : style); @@ -966,12 +999,8 @@ void gnuplot_plot_slope (gnuplot_ctrl *handle, double a, double b, char *title) void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title) { char cmd[GP_CMD_SIZE]; - char plot_str[GP_EQ_SIZE]; - char title_str[GP_TITLE_SIZE]; - strcpy(plot_str, (handle->nplots > 0) ? "replot" : "plot"); - strcpy(title_str, (title == NULL) ? "no title" : title); - sprintf(cmd, "%s %s title \"%s\" with %s", plot_str, equation, title_str, handle->pstyle); + sprintf(cmd, "%s %s title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", equation, (title) ? title : "No title", handle->pstyle); gnuplot_cmd(handle, cmd); handle->nplots++; } From 6c42d8352ad6a3ab029f281f356c495a2bf9155f Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sat, 15 Jul 2023 14:02:24 +0200 Subject: [PATCH 036/128] Update gnuplot_i.h * Add print_gnuplot_handle function --- gnuplot_i.h | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/gnuplot_i.h b/gnuplot_i.h index 636515e..e0bfeda 100755 --- a/gnuplot_i.h +++ b/gnuplot_i.h @@ -11,7 +11,7 @@ $Author: ndevilla $ $Date: 2003/01/27 08:58:04 $ $Revision: 1.11.2 $ - */ +*/ #ifndef _GNUPLOT_PIPES_H_ #define _GNUPLOT_PIPES_H_ @@ -37,49 +37,48 @@ New Types ---------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------*/ /** @typedef gnuplot_ctrl @brief gnuplot session handle. - @param gnucmd Pipe to gnuplot process. - @param nplots Number of currently active plots. - @param pstyle Current plotting style. - @param term Save terminal name (used by hardcopy functions). - @param to_delete Name of temporary files. - @param ntmp Number of temporary files. + @param gnucmd + @param nplots + @param pstyle + @param term + @param to_delete + @param ntmp This structure holds all necessary information to talk to a gnuplot session. It is built and returned by gnuplot_init() and later used by all functions in this module to communicate with the session, then meant to be closed by gnuplot_close(). - - This structure is meant to remain opaque to the developer, so that its - contents are not to be directly used. - */ +*/ typedef struct _GNUPLOT_CTRL_ { - FILE *gnucmd; - int nplots; - char pstyle[32]; - char term[32]; - char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE]; - int ntmp; + FILE *gnucmd; /*!< Pipe to gnuplot process. */ + int nplots; /*!< Number of currently active plots. */ + char pstyle[32]; /*!< Current plotting style. */ + char term[32]; /*!< Save terminal name (used by `gnuplot_hardcopy()` function). */ + char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE]; /*!< Names of temporary files. */ + int ntmp; /*!< Number of temporary files in the current session. */ } gnuplot_ctrl; +/*-------------------------------------------------------------------------*/ /** @typedef gnuplot_point - @param x X-coodinate (double). - @param y Y-coodinate (double). - @param z Z-coodinate (double). @brief gnuplot point structure, ie set of [x,y,z] coordinates. + @param x + @param y + @param z gnuplot_point is a point struct to allow the return of points to the `gnuplot_plot_obj_xy` function by callback functions. */ typedef struct _GNUPLOT_POINT_ { - double x; - double y; - double z; + double x; /*!< X-coodinate */ + double y; /*!< Y-coodinate */ + double z; /*!< Z-coodinate */ } gnuplot_point; /*--------------------------------------------------------------------------- @@ -93,10 +92,11 @@ char *gnuplot_get_program_path (char *pname); /* gnuplot interface handling functions */ gnuplot_ctrl *gnuplot_init (void); +void print_gnuplot_handle (gnuplot_ctrl *handle); void gnuplot_close (gnuplot_ctrl *handle); void gnuplot_cmd (gnuplot_ctrl *handle, char *cmd, ...); void gnuplot_setstyle (gnuplot_ctrl *handle, char *plot_style); -void gnuplot_setterm (gnuplot_ctrl *handle, char *terminal); +void gnuplot_setterm (gnuplot_ctrl *handle, char *terminal, int width, int height); void gnuplot_set_axislabel (gnuplot_ctrl *handle, char *label, char *axis); void gnuplot_resetplot (gnuplot_ctrl *handle); From eca6f99aabdaffbd6046eb90c1be5b647eb861ee Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sat, 15 Jul 2023 14:08:12 +0200 Subject: [PATCH 037/128] Update example.c * Examples review, integration test --- examples/example.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/examples/example.c b/examples/example.c index 535cc50..5b4d822 100644 --- a/examples/example.c +++ b/examples/example.c @@ -20,7 +20,8 @@ int main(int argc, char *argv[]) { printf("*** Example of gnuplot control through C ***\n"); h1 = gnuplot_init(); - gnuplot_setterm(h1 , "wxt"); + gnuplot_setterm(h1, "wxt", 900, 400); + /** Slopes */ gnuplot_setstyle(h1, "lines"); @@ -38,8 +39,7 @@ int main(int argc, char *argv[]) { /** Equations */ gnuplot_resetplot(h1); - printf("\n\n"); - printf("*** various equations\n"); + printf("\n*** various equations\n"); printf("y = sin(x)\n"); gnuplot_plot_equation(h1, "sin(x)", "sine"); sleep(SECONDS); @@ -53,8 +53,7 @@ int main(int argc, char *argv[]) { /** Styles */ gnuplot_resetplot(h1); - printf("\n\n"); - printf("*** showing styles\n"); + printf("\n*** showing styles\n"); printf("sine in points\n"); gnuplot_setstyle(h1, "points"); gnuplot_plot_equation(h1, "sin(x)", "sine"); @@ -63,17 +62,18 @@ int main(int argc, char *argv[]) { gnuplot_setstyle(h1, "impulses"); gnuplot_plot_equation(h1, "sin(x)", "sine"); sleep(SECONDS); - printf("sine in steps\n"); + printf("arctangens in steps\n"); gnuplot_setstyle(h1, "steps"); - gnuplot_plot_equation(h1, "sin(x)", "sine"); + gnuplot_plot_equation(h1, "atan(x)", "arctangens"); sleep(SECONDS); /** User defined 1d and 2d point sets */ gnuplot_resetplot(h1); gnuplot_setstyle(h1, "impulses"); - printf("\n\n"); - printf("*** user-defined lists of doubles\n"); + gnuplot_set_axislabel(h1, "X", "x"); + gnuplot_set_axislabel(h1, "quadratic", "y"); + printf("\n*** user-defined lists of doubles\n"); for (i = 0; i < NPOINTS; i++) { x[i] = (double)i * i; } @@ -91,8 +91,7 @@ int main(int argc, char *argv[]) { /** Multiple output screens */ - printf("\n\n"); - printf("*** multiple output windows\n"); + printf("\n*** multiple output windows\n"); gnuplot_resetplot(h1); gnuplot_setstyle(h1, "lines"); h2 = gnuplot_init(); @@ -116,8 +115,7 @@ int main(int argc, char *argv[]) { /** Close gnuplot handles */ - printf("\n\n"); - printf("*** closing all gnuplot windows\n"); + printf("\n*** closing all gnuplot windows\n"); gnuplot_close(h1); gnuplot_close(h2); gnuplot_close(h3); From 496b2bb2c2ce37c9f298ad1ff1c18cfdc9cbe4ab Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sat, 15 Jul 2023 14:17:02 +0200 Subject: [PATCH 038/128] Update README.md * Updates based on recent developments --- README.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e78a786..6afb100 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,15 @@ Overview -------- The `gnuplot_i` interface library enables developers to create [gnuplots](http://www.gnuplot.info/) from their C programs. -It was originally developed by Nicolas Devillard (2000) who also placed it in the public domain. -Numerous authors have contributed to this package, among which Peter Maresh to compile and run on MS-Windows 7/64 using mingw64. +Provenance +---------- -The library was since enhanced by Robert Bradley (2004-2006). +It was originally developed by Nicolas Devillard (2000) who also placed it in the public domain. +Other authors have contributed to this library: +* Peter Maresh (2010): compile and run on MS-Windows 7/64 using mingw64. +* Robert Bradley (2004-2006): functional enhancements, see next section. +* longradix (2023): refactoring, error handling, stylistic improvements, documentation updates. Enhancements @@ -21,7 +25,7 @@ This interface library features the following enhancements: * Setting z-axis labels with `gnuplot_set_axislabel(handle, "z-axis label", "z")`. * Production of colour PostScript files with `gnuplot_hardcopy(handle, "graph.ps")`. * Windows support. -* On OS X, if DISPLAY environment variable is not set or USE_AQUA=1, then aqua is used instead of x11. +* On OS X, if `DISPLAY` environment variable is not set or `USE_AQUA=1`, then aqua is used instead of x11. * Plotting of complex structures through the use of callbacks, see `gnuplot_plot_obj_xy` and `gnuplot_splot_obj`. * Contour plotting with `gnuplot_setstyle(handle, "lines")` and `gnuplot_contour_plot(handle, x, y, z, nx, ny, "title")`. @@ -33,9 +37,9 @@ Examples This library comes with the following examples: -* example.c: a garden variety of `gnuplot_i` function calls to demonstrate general usage and capabilities. -* animation.c: a brief animation of a run-time generated sine wave. -* sinepng.c: a demonstration of how `gnuplot_i` can be used to store its output as a file. +* **example.c**: a garden variety of `gnuplot_i` function calls to demonstrate general usage and capabilities. +* **animation.c**: a brief animation of a run-time generated sine wave. +* **sinepng.c**: a demonstration of how `gnuplot_i` can be used to store its output as a file. Compilation instructions are included in each of these examples. @@ -43,7 +47,7 @@ Compilation instructions are included in each of these examples. Changelog --------- -29 May 2023 - Refactoring, stylistic improvements, documentation updates. +29 May 2023 - Refactoring, error handling, stylistic improvements, documentation updates. 02 Apr 2006 - Added `gnuplot_splot_grid` for plotting 2D arrays of data, and restored the lost contour plotting code. From 038d17ef3324ade3ca395a7b7c8cfa0fbafbb499 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sat, 15 Jul 2023 14:40:31 +0200 Subject: [PATCH 039/128] Update animation.c * Update documentation --- examples/animation.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/animation.c b/examples/animation.c index 14e415c..be64ddf 100644 --- a/examples/animation.c +++ b/examples/animation.c @@ -2,7 +2,11 @@ * Examples of gnuplot_i.c usage * Compilation: gcc -Wall -g animation.c gnuplot_i.c -o animation * - * This program produces an animated sine wave in a gnuplot window + * This program produces an animated sine wave in a gnuplot window. + * It does so by reeatedly calling gnuplot_resetplot() and gnuplot_cmd() + * in a loop. + * The gnuplot window closes after all equation-plots have been generated. + * */ #include From 449a50d0c2fa5b8e46f0d3b95023ab57335f7568 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sat, 15 Jul 2023 20:48:13 +0200 Subject: [PATCH 040/128] Update gnuplot_i.c * Removal of redundant `gnuplot_plot_slope` function: can be handled via `gnuplot_plot_equation`. * Code comment updates --- gnuplot_i.c | 54 ++++++++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index cb6e25b..b2916f3 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -12,6 +12,16 @@ gnuplot_i is a C interface library that enables sending display requests to gnuplot through C calls. gnuplot itself is an open source plotting library also written in C. + + Example of a minimal structure: + + @code + gnuplot_ctrl *handle = gnuplot_init(); + gnuplot_cmd(handle, "set terminal png"); + gnuplot_plot_equation(handle, "sin(x)", "Sine wave"); + gnuplot_close(handle); + @endcode + */ /*--------------------------------------------------------------------------*/ @@ -273,8 +283,11 @@ void gnuplot_close (gnuplot_ctrl *handle) { @param handle Gnuplot session control handle @param cmd Command to send, same as a printf statement. - This sends a string to an active gnuplot session, to be executed. - There is no way to know if the command has been successfully executed or not. + This sends a string to an active gnuplot session to be executed. + This function is the fallback option: if a certain functionality is not + supported by one of the functions, it is in most cases possible to send + the required gnuplot commands using this function. + The command syntax is the same as printf. Examples: @@ -406,6 +419,9 @@ void gnuplot_set_axislabel (gnuplot_ctrl *handle, char *label, char *axis) { @return void Resets a gnuplot session, i.e. the next plot will erase all previous ones. + This function can effectively be used to insert a new plot in the same + window with all options maintained. As such, it can be used to create + animations. */ /*--------------------------------------------------------------------------*/ @@ -938,40 +954,6 @@ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, gnuplot_close(handle); } -/*-------------------------------------------------------------------------*/ -/** - @brief Plot a slope (linear equation) on a gnuplot session. - @param handle Gnuplot session control handle. - @param a Slope. - @param b Intercept. - @param title Title of the plot (can be NULL). - @return void - - Plot a slope on a gnuplot session. The general form of the equation is y=ax+b, - where only the slope a and intercept b are provided. - - Example: - - @code - gnuplot_ctrl *h; - double a, b; - - h = gnuplot_init(); - gnuplot_plot_slope(h, 1.0, 0.0, "unity slope"); - sleep(2); - gnuplot_close(h); - @endcode - */ -/*--------------------------------------------------------------------------*/ - -void gnuplot_plot_slope (gnuplot_ctrl *handle, double a, double b, char *title) { - char cmd[GP_CMD_SIZE]; - - sprintf(cmd, "%s %g * x + %g title \"%s\" with %s", (handle->nplots > 0) ? "replot" : "plot", a, b, (title) ? title : "No title", handle->pstyle); - gnuplot_cmd(handle, cmd); - handle->nplots++; -} - /*-------------------------------------------------------------------------*/ /** @brief Plot a curve of given equation y=f(x). From 666d3740105ad4716702b22e9b0a79451386aa98 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sat, 15 Jul 2023 20:48:58 +0200 Subject: [PATCH 041/128] Update gnuplot_i.h * Removal of redundant `gnuplot_plot_slope` function --- gnuplot_i.h | 1 - 1 file changed, 1 deletion(-) diff --git a/gnuplot_i.h b/gnuplot_i.h index e0bfeda..e55c67e 100755 --- a/gnuplot_i.h +++ b/gnuplot_i.h @@ -110,7 +110,6 @@ void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, double *x, double *y, int n); -void gnuplot_plot_slope (gnuplot_ctrl *handle, double a, double b, char *title); void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title); void gnuplot_hardcopy (gnuplot_ctrl *handle, char *filename, char *color); From 97322d515833f135d2bdf075950fa41e2cd579c2 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 10:03:31 +0200 Subject: [PATCH 042/128] Update example.c * Add splot example * Remove deprecated gnuplot_slope reference --- examples/example.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/examples/example.c b/examples/example.c index 5b4d822..9397f1b 100644 --- a/examples/example.c +++ b/examples/example.c @@ -1,19 +1,20 @@ /* * Examples of gnuplot_i.c usage - * Compilation: gcc -Wall -g example.c gnuplot_i.c -o example + * Compilation: gcc -Wall -g example.c gnuplot_i.c -o example -lm * */ #include #include +#include #include "gnuplot_i.h" -#define SECONDS 1 +#define SECONDS 3 #define NPOINTS 50 int main(int argc, char *argv[]) { gnuplot_ctrl *h1, *h2, *h3, *h4; - double x[NPOINTS], y[NPOINTS]; + double x[NPOINTS], y[NPOINTS], z[NPOINTS]; int i; /** Initialize the gnuplot handle */ @@ -22,20 +23,6 @@ int main(int argc, char *argv[]) { h1 = gnuplot_init(); gnuplot_setterm(h1, "wxt", 900, 400); - /** Slopes */ - - gnuplot_setstyle(h1, "lines"); - printf("*** plotting slopes\n"); - printf("y = x\n"); - gnuplot_plot_slope(h1, 1.0, 0.0, "unity slope"); - sleep(SECONDS); - printf("y = 2*x\n"); - gnuplot_plot_slope(h1, 2.0, 0.0, "y=2x"); - sleep(SECONDS); - printf("y = -x\n"); - gnuplot_plot_slope(h1, -1.0, 0.0, "y=-x"); - sleep(SECONDS); - /** Equations */ gnuplot_resetplot(h1); @@ -43,8 +30,9 @@ int main(int argc, char *argv[]) { printf("y = sin(x)\n"); gnuplot_plot_equation(h1, "sin(x)", "sine"); sleep(SECONDS); - printf("y = log(x)\n"); - gnuplot_plot_equation(h1, "log(x)", "logarithm"); + printf("y = 2*x-1\n"); + gnuplot_setstyle(h1, "dots"); + gnuplot_plot_equation(h1, "2*x-1", "slope"); sleep(SECONDS); printf("y = sin(x)*cos(2*x)\n"); gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product"); @@ -89,6 +77,22 @@ int main(int argc, char *argv[]) { gnuplot_plot_xy(h1, x, y, NPOINTS, "user-defined points"); sleep(SECONDS); + /** Splot example */ + + gnuplot_resetplot(h1); + gnuplot_setstyle(h1, "lines"); + gnuplot_set_axislabel(h1, "X", "x"); + gnuplot_set_axislabel(h1, "Y", "y"); + gnuplot_set_axislabel(h1, "Z-axis", "z"); + for (int i = 0; i < NPOINTS; i++) { + x[i] = 2*sin((double)i/3); + y[i] = 5*sin((double)i/2 + 1); + z[i] = x[i] + y[i]; + } + print_gnuplot_handle(h1); // Showing internal debugging information + gnuplot_splot(h1, x, y, z, NPOINTS, "Lissajous"); + sleep(SECONDS); + /** Multiple output screens */ printf("\n*** multiple output windows\n"); From 1991c1de45df74d5413c3f4a8fe08e3388a0e451 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 10:46:15 +0200 Subject: [PATCH 043/128] Update TODO * Add whether test is needed for availability of wxWidgets --- TODO | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO b/TODO index b3c66e2..f328006 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,6 @@ * More unit tests to be added as not all functions are being covered by tests, notably 3D plots, such as contourplots and heatmaps. * Further refactoring. +* wxt is the default terminal type, but need a test to check whether wxWidgets is actually installed. * Plotting styles have been added to gnuplot since this interface library was completed, hence further testing and documentation on this. * More field testing is needed: - Does the current version still work on Windows / OS-X / other operating systems? From 24ea49d1be691ddbffcd8b89d13ad6e0ac42bd1b Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 11:08:01 +0200 Subject: [PATCH 044/128] Update README.md * Add more information to overview --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 6afb100..1c8474b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,20 @@ Overview The `gnuplot_i` interface library enables developers to create [gnuplots](http://www.gnuplot.info/) from their C programs. +It works by creating a UNIX pipe through which gnuplot commands are sent and then executed. + +The central data structure is the gnuplot control handle, which holds the gnuplot commands as well as technical internal information, such as terminal type, amount of open windows and such. + +The plot is displayed in its own window or saved as an image file to disk. + +Example of a minimal structure: + + gnuplot_ctrl *handle = gnuplot_init(); + gnuplot_cmd(handle, "set terminal png"); + gnuplot_plot_equation(handle, "sin(x)", "Sine wave"); + gnuplot_close(handle); + + Provenance ---------- From 7ff527497b232d4eddd4e837a3cc5d90bb111384 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 11:59:31 +0200 Subject: [PATCH 045/128] Update and rename gnuplot_i.txt to gnuplot_i.md * Review based on latest `gnuplot` functions * Marked down --- gnuplot_i.md | 135 +++++++++++++++++++++++++++++++++++++++++++++ gnuplot_i.txt | 148 -------------------------------------------------- 2 files changed, 135 insertions(+), 148 deletions(-) create mode 100644 gnuplot_i.md delete mode 100644 gnuplot_i.txt diff --git a/gnuplot_i.md b/gnuplot_i.md new file mode 100644 index 0000000..ff5e8a3 --- /dev/null +++ b/gnuplot_i.md @@ -0,0 +1,135 @@ +gnuplot_i tutorial +================== + +gnuplot_i (formerly known as gnuplot_pipes) is a programmer-friendly set of C routines to use `gnuplot` as a data displayer from a C program. + +Gnuplot must be installed to use this library. + +The procedure to display graphics in a gnuplot session is as follows: + +1. Open a new gnuplot session, referenced by a handle of type (pointer to) `gnuplot_ctrl`. This is done by calling `gnuplot_init()`: + + gnuplot_ctrl * h; + h = gnuplot_init(); + + The variable h will be used as the handle to the gnuplot session which was just opened, by all further functions. + + +2. Send display configuration options. The following functions to set these options are available: + + gnuplot_setstyle (handle, style) + sets the plotting style of the next plots + + gnuplot_set_axislabel (handle, label, axis) + sets the label for the axis identified by variable `axis` (x, y or z) + + Examples: + + gnuplot_setstyle (h, "impulses"); + gnuplot_set_axislabel (h, "my X label", 'x'); + gnuplot_set_axislabel (h, "my Y label", 'y'); + + The critical routine is `gnuplot_cmd()`, which sends character strings to gnuplot as though they were typed in by a user. This routine works in a printf fashion, accepting the same kind of format string and variable number of arguments. + + The prototype is: + + gnuplot_cmd(handle, command, ...) + + Example: + + char myfile[] = "/data/file_in.dat"; + + gnuplot_cmd(handle, "plot '%s'", myfile); + for (int i = 0; i < 10; i++) { + gnuplot_cmd (handle, "plot y=%d*x", i); + } + + The following commands request the output to be done to a Postscript file named 'curve.ps': + + gnuplot_cmd(h, "set terminal postscript"); + gnuplot_cmd(h, "set output \"curve.ps\""); + + With gnuplot_cmd() it should be easy to add up some more configuration related functions where needed. + + +3. Send some display orders: either functions or doubles, or double points. The following functions are available: + + void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title); + Plots a 2d graph from a list of doubles. The x-coordinate is the index of the double in the list, the y coordinate is the double in the list. + + void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *title); + Plots a 2d graph from a list of points. Provide points through a list of x and a list of y coordinates. Both arrays are assumed to contain the same number of values. + + void gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char *title); + Plots a 3d graph from a list of points, passed as arrays x, y and z. All arrays are assumed to contain the same number of values. + + void gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols, char *title); + Plots a 3d graph from a grid of points, passed in the form of an array [x,y]. + + void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, int nx, int ny, char *title); + Plots a contour plot from a list of points, passed as arrays x, y and z. + + void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); + Plots a 3d graph using callback functions to return the points. + + void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); + Plots a 2d graph using a callback function to return points. + + void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, double *x, double *y, int n); + Opens a new gnuplot session, plots the provided signal as an X or XY signal depending on a provided y, waits for a carriage return on stdin and closes the session. + + void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title); + Plots a given equation. The general form of the equation is y=f(x), by providing the f(x) side of the equation only. + + void gnuplot_hardcopy (gnuplot_ctrl *handle, char *filename, char *color); + Sets the terminal to Postscript, replots the graph and then resets the terminal back to x11. The use of this function supposes that it will be used in combination with one of the plotting functions. + + gnuplot_resetplot(gnuplot_ctrl *handle) + Clears the current gnuplot display before the next plot is inserted into the same gnuplot window. + + +4. Close the gnuplot handle, which also removes all temporary gnuplot files from `/tmp` and `/var/tmp`. + + gnuplot_close(h); + + +See examples of `gnuplot_i` usage in the file 'example.c'. + + +Some more points before you start using gnuplot_i +------------------------------------------------- + +Note that it is possible to open several gnuplot sessions from the same program. Just be careful as to which session you are talking to when using functions. Example: + + h1 = gnuplot_init(); + h2 = gnuplot_init(); + + gnuplot_plot_equation(h1, "sin(x)", "sine on first session"); + gnuplot_plot_equation(h2, "log(x)", "log on second session"); + sleep(3); + gnuplot_close(h1); + gnuplot_close(h2); + +Do not forget to close opened sessions. Not closing a session would pollute your system with temporary files. Normally your temporary directories should be cleaned automatically so every now and then, but best is to close all windows prior to closing the session. + +User interactions are not part of gnuplot_i. Feel free to use your own. + +No timing mechanisms are provided to leave the outputs on screen until e.g. a key is pressed. I leave it up to gnuplot_i users to provide that kind of functionality in their own application, depending on the kind of interaction they need. + +gnuplot_i is completely free software. Use it for whatever you want to do with it without any fee, and do not hesitate to send feedback to me: + + + +If you can, I would appreciate a mention somewhere that you are using `gnuplot_i` in your application. Something like: + + "This software uses the gnuplot_i library written by N.Devillard ." + +If you are using gnuplot_i for a web-based application, you can also add a link to the gnuplot home page: + + http://ndevilla.free.fr/ + +If you are so happy about this piece of code that you would like to fund more stuff like that, do not hesitate to send me cash :-) + + +Nicolas Devillard - April 2000 +longradix - July 2023 diff --git a/gnuplot_i.txt b/gnuplot_i.txt deleted file mode 100644 index d6176e5..0000000 --- a/gnuplot_i.txt +++ /dev/null @@ -1,148 +0,0 @@ - -gnuplot_i: a short documentation --------------------------------- - -gnuplot_i (formerly known as gnuplot_pipes) provides a programmer-friendly -set of routines to use gnuplot as a data displayer from a C program. - -Gnuplot must be installed to use this package. - -The procedure to display graphics in a gnuplot session is: - -1. Open a new gnuplot session, referenced by a handle of type (pointer to) - gnuplot_ctrl. This is done by calling gnuplot_init(): - - gnuplot_ctrl * h; - h = gnuplot_init(); - - h will be used as the handle to the gnuplot session which was just opened, - by all further functions. - - -2. Send optionally display configuration orders. The following functions - are available: - - gnuplot_setstyle (handle, style) - sets the plotting style of the next plots - - gnuplot_set_xlabel (handle, label) - sets the X label for the next plots - - gnuplot_set_ylabel (handle, label) - sets the Y label for the next plots - - Examples: - - gnuplot_setstyle (h, "impulses"); - gnuplot_set_axislabel (h, "my X label", 'x'); - gnuplot_set_axislabel (h, "my Y label", 'y'); - - The most critical routine is gnuplot_cmd(), which sends character strings - to gnuplot as though they were typed in by a user. This routine works in a - printf fashion, accepting the same kind of format string and variable number - of arguments. - - The prototype is: - - gnuplot_cmd(handle, command, ...) - - Example: - - char myfile[] = "/data/file_in.dat"; - - gnuplot_cmd(handle, "plot '%s'", myfile); - for (int i = 0; i < 10; i++) { - gnuplot_cmd (handle, "plot y=%d*x", i); - } - - The following commands request the output to be done to a Postscript file - named 'curve.ps': - - gnuplot_cmd(h, "set terminal postscript"); - gnuplot_cmd(h, "set output \"curve.ps\""); - - With gnuplot_cmd() it should be easy to add up some more configuration - related functions where needed. - - -3. Send some display orders: either functions or doubles, or double points. - The following functions are available: - - gnuplot_plot_slope() - to display a slope - - gnuplot_plot_equation() - to display an equation - - gnuplot_plot_1d_var1() - to display user-defined 1d data with a single variable. - Input is a list of values, assumed regularly spaced on the - X-axis. - - gnuplot_plot_1d_var2() - to display user-defined 1d data with two variables. - Input is a list of point coordinates. The 'dpoint' struct - type is provided for that purpose. - - gnuplot_resetplot() - states that the current gnuplot display will be cleared - before next display is done. - - -4. Close the gnuplot handle. This is important, since otherwise not all - temporary files will be cleaned for /tmp and /var/tmp. - - gnuplot_close(h); - - -See example of gnuplot_i use in the provided file 'example.c'. - - -Some more points before you start using gnuplot_i -------------------------------------------------- - - Notice that it is possible to open several gnuplot sessions from the same - program. Just be careful as to which session you are talking to when using - functions. Example: - - h1 = gnuplot_init(); - h2 = gnuplot_init(); - - gnuplot_plot_equation(h1, "sin(x)", "sine on first session"); - gnuplot_plot_equation(h2, "log(x)", "log on second session"); - sleep(3); - gnuplot_close(h1); - gnuplot_close(h2); - - Never forget to close opened sessions! This would leave temporary files. - Normally your temporary directories should be cleaned automatically so every - now and then, but best is to close all windows prior to closing the session. - - User interactions are not part of gnuplot_i. Feel free to use your own. - - No timing mechanisms are provided to leave the outputs on screen - until e.g. a key is pressed. I leave it up to gnuplot_i users to provide - that kind of functionality in their own application, depending on the - kind of interaction they need. - - gnuplot_i is completely free software. Use it for whatever you want to do - with it without any fee, and do not hesitate to send feedback to me: - - - - If you can, I would appreciate a mention somewhere that you are using - 'gnuplot_i' in your application. Something like: - - "This software uses the gnuplot_i library written by - N.Devillard ." - - If you are using gnuplot_i for a web-based application, you can also add - a link to the gnuplot home page: - - http://ndevilla.free.fr/ - - If you are so happy about this piece of code that you would like - to fund more stuff like that, do not hesitate to send me cash :-) - - -Nicolas Devillard -- April 2000 From 5889473d4b5a78d29004cfe871085f0d0c67bf79 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:08:51 +0200 Subject: [PATCH 046/128] Update gnuplot_i.md * Markdown style --- gnuplot_i.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gnuplot_i.md b/gnuplot_i.md index ff5e8a3..aa4730e 100644 --- a/gnuplot_i.md +++ b/gnuplot_i.md @@ -55,36 +55,47 @@ The procedure to display graphics in a gnuplot session is as follows: 3. Send some display orders: either functions or doubles, or double points. The following functions are available: void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title); + Plots a 2d graph from a list of doubles. The x-coordinate is the index of the double in the list, the y coordinate is the double in the list. void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *title); + Plots a 2d graph from a list of points. Provide points through a list of x and a list of y coordinates. Both arrays are assumed to contain the same number of values. void gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char *title); + Plots a 3d graph from a list of points, passed as arrays x, y and z. All arrays are assumed to contain the same number of values. void gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols, char *title); + Plots a 3d graph from a grid of points, passed in the form of an array [x,y]. void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, int nx, int ny, char *title); + Plots a contour plot from a list of points, passed as arrays x, y and z. void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); + Plots a 3d graph using callback functions to return the points. void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); + Plots a 2d graph using a callback function to return points. void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, double *x, double *y, int n); + Opens a new gnuplot session, plots the provided signal as an X or XY signal depending on a provided y, waits for a carriage return on stdin and closes the session. void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title); + Plots a given equation. The general form of the equation is y=f(x), by providing the f(x) side of the equation only. void gnuplot_hardcopy (gnuplot_ctrl *handle, char *filename, char *color); + Sets the terminal to Postscript, replots the graph and then resets the terminal back to x11. The use of this function supposes that it will be used in combination with one of the plotting functions. gnuplot_resetplot(gnuplot_ctrl *handle) + Clears the current gnuplot display before the next plot is inserted into the same gnuplot window. From 600794e78b8e3849fc8b51e98ca3c91a064532bd Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:10:09 +0200 Subject: [PATCH 047/128] Update gnuplot_i.md * Markdown style --- gnuplot_i.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/gnuplot_i.md b/gnuplot_i.md index aa4730e..ce9e18a 100644 --- a/gnuplot_i.md +++ b/gnuplot_i.md @@ -56,47 +56,47 @@ The procedure to display graphics in a gnuplot session is as follows: void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title); - Plots a 2d graph from a list of doubles. The x-coordinate is the index of the double in the list, the y coordinate is the double in the list. + Plots a 2d graph from a list of doubles. The x-coordinate is the index of the double in the list, the y coordinate is the double in the list. void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *title); - Plots a 2d graph from a list of points. Provide points through a list of x and a list of y coordinates. Both arrays are assumed to contain the same number of values. + Plots a 2d graph from a list of points. Provide points through a list of x and a list of y coordinates. Both arrays are assumed to contain the same number of values. void gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n, char *title); - Plots a 3d graph from a list of points, passed as arrays x, y and z. All arrays are assumed to contain the same number of values. + Plots a 3d graph from a list of points, passed as arrays x, y and z. All arrays are assumed to contain the same number of values. void gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int cols, char *title); - Plots a 3d graph from a grid of points, passed in the form of an array [x,y]. + Plots a 3d graph from a grid of points, passed in the form of an array [x,y]. void gnuplot_contour_plot (gnuplot_ctrl *handle, double *x, double *y, double *z, int nx, int ny, char *title); - Plots a contour plot from a list of points, passed as arrays x, y and z. + Plots a contour plot from a list of points, passed as arrays x, y and z. void gnuplot_splot_obj (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); - Plots a 3d graph using callback functions to return the points. + Plots a 3d graph using callback functions to return the points. void gnuplot_plot_obj_xy (gnuplot_ctrl *handle, void *obj, void (*getPoint)(void *, gnuplot_point *, int, int), int n, char *title); - Plots a 2d graph using a callback function to return points. + Plots a 2d graph using a callback function to return points. void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, double *x, double *y, int n); - Opens a new gnuplot session, plots the provided signal as an X or XY signal depending on a provided y, waits for a carriage return on stdin and closes the session. + Opens a new gnuplot session, plots the provided signal as an X or XY signal depending on a provided y, waits for a carriage return on stdin and closes the session. void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title); - Plots a given equation. The general form of the equation is y=f(x), by providing the f(x) side of the equation only. + Plots a given equation. The general form of the equation is y=f(x), by providing the f(x) side of the equation only. void gnuplot_hardcopy (gnuplot_ctrl *handle, char *filename, char *color); - Sets the terminal to Postscript, replots the graph and then resets the terminal back to x11. The use of this function supposes that it will be used in combination with one of the plotting functions. + Sets the terminal to Postscript, replots the graph and then resets the terminal back to x11. The use of this function supposes that it will be used in combination with one of the plotting functions. gnuplot_resetplot(gnuplot_ctrl *handle) - Clears the current gnuplot display before the next plot is inserted into the same gnuplot window. + Clears the current gnuplot display before the next plot is inserted into the same gnuplot window. 4. Close the gnuplot handle, which also removes all temporary gnuplot files from `/tmp` and `/var/tmp`. @@ -142,5 +142,5 @@ If you are using gnuplot_i for a web-based application, you can also add a link If you are so happy about this piece of code that you would like to fund more stuff like that, do not hesitate to send me cash :-) -Nicolas Devillard - April 2000 -longradix - July 2023 +* Nicolas Devillard - April 2000 +* longradix - July 2023 From 6dce88a5638b82ecf11f7d796e78935e9591c90b Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:18:28 +0200 Subject: [PATCH 048/128] Update gnuplot_i.md * Markdown style --- gnuplot_i.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gnuplot_i.md b/gnuplot_i.md index ce9e18a..5ef5dd0 100644 --- a/gnuplot_i.md +++ b/gnuplot_i.md @@ -1,10 +1,16 @@ gnuplot_i tutorial ================== +Introduction +------------ + gnuplot_i (formerly known as gnuplot_pipes) is a programmer-friendly set of C routines to use `gnuplot` as a data displayer from a C program. Gnuplot must be installed to use this library. +Tutorial +-------- + The procedure to display graphics in a gnuplot session is as follows: 1. Open a new gnuplot session, referenced by a handle of type (pointer to) `gnuplot_ctrl`. This is done by calling `gnuplot_init()`: @@ -17,11 +23,17 @@ The procedure to display graphics in a gnuplot session is as follows: 2. Send display configuration options. The following functions to set these options are available: + gnuplot_setterm (gnuplot_ctrl *handle, char *terminal, int width, int height) + + Sets the terminal type ('wxt', 'aqua', 'x11', 'png', 'windows') for the correct system-dependent display of the plot. + gnuplot_setstyle (handle, style) - sets the plotting style of the next plots + + Sets the plotting style of the next plots gnuplot_set_axislabel (handle, label, axis) - sets the label for the axis identified by variable `axis` (x, y or z) + + Sets the label for the axis identified by variable `axis` (x, y or z) Examples: @@ -52,7 +64,7 @@ The procedure to display graphics in a gnuplot session is as follows: With gnuplot_cmd() it should be easy to add up some more configuration related functions where needed. -3. Send some display orders: either functions or doubles, or double points. The following functions are available: +3. Send one of the following display functions: void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title); From 46f61e583a8734e0ffdf28fd348179c3aecb2d56 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:23:18 +0200 Subject: [PATCH 049/128] Update gnuplot_i.md * Markdown style --- gnuplot_i.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gnuplot_i.md b/gnuplot_i.md index 5ef5dd0..297e738 100644 --- a/gnuplot_i.md +++ b/gnuplot_i.md @@ -13,7 +13,9 @@ Tutorial The procedure to display graphics in a gnuplot session is as follows: -1. Open a new gnuplot session, referenced by a handle of type (pointer to) `gnuplot_ctrl`. This is done by calling `gnuplot_init()`: +1. Open a new gnuplot session, referenced by a handle of type (pointer to) `gnuplot_ctrl`. This is done by calling `gnuplot_init()`. + + Example: gnuplot_ctrl * h; h = gnuplot_init(); From c95788bef2992764ff3f722f513a4f2f7e7a987d Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:28:01 +0200 Subject: [PATCH 050/128] Update gnuplot_i.md * Markdown style --- gnuplot_i.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gnuplot_i.md b/gnuplot_i.md index 297e738..438d0ae 100644 --- a/gnuplot_i.md +++ b/gnuplot_i.md @@ -8,6 +8,7 @@ gnuplot_i (formerly known as gnuplot_pipes) is a programmer-friendly set of C ro Gnuplot must be installed to use this library. + Tutorial -------- @@ -23,7 +24,9 @@ The procedure to display graphics in a gnuplot session is as follows: The variable h will be used as the handle to the gnuplot session which was just opened, by all further functions. -2. Send display configuration options. The following functions to set these options are available: +2. Send display configuration options. + + The following functions to set these options are available: gnuplot_setterm (gnuplot_ctrl *handle, char *terminal, int width, int height) @@ -66,7 +69,9 @@ The procedure to display graphics in a gnuplot session is as follows: With gnuplot_cmd() it should be easy to add up some more configuration related functions where needed. -3. Send one of the following display functions: +3. Send a display function. + + The following display functions are available: void gnuplot_plot_x (gnuplot_ctrl *handle, double *x, int n, char *title); @@ -115,6 +120,8 @@ The procedure to display graphics in a gnuplot session is as follows: 4. Close the gnuplot handle, which also removes all temporary gnuplot files from `/tmp` and `/var/tmp`. + Syntax: + gnuplot_close(h); From 93b7ad5b6f870d6450b3cda0f3e8c81406759e20 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:33:18 +0200 Subject: [PATCH 051/128] Update gnuplot_i.md * Stylistic improvements --- gnuplot_i.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gnuplot_i.md b/gnuplot_i.md index 438d0ae..e37ee6e 100644 --- a/gnuplot_i.md +++ b/gnuplot_i.md @@ -128,8 +128,8 @@ The procedure to display graphics in a gnuplot session is as follows: See examples of `gnuplot_i` usage in the file 'example.c'. -Some more points before you start using gnuplot_i -------------------------------------------------- +Additional remarks +------------------ Note that it is possible to open several gnuplot sessions from the same program. Just be careful as to which session you are talking to when using functions. Example: @@ -142,13 +142,13 @@ Note that it is possible to open several gnuplot sessions from the same program. gnuplot_close(h1); gnuplot_close(h2); -Do not forget to close opened sessions. Not closing a session would pollute your system with temporary files. Normally your temporary directories should be cleaned automatically so every now and then, but best is to close all windows prior to closing the session. +Do not forget to close an opened sessions. Not closing a session would pollute your system with temporary files. Normally your temporary directories should be cleaned automatically, for example after a restart, but closing all windows prior to closing the session is recommended. -User interactions are not part of gnuplot_i. Feel free to use your own. +User interactions are not part of `gnuplot_i`. It is however possible to rotate a 3D plot with the mouse for example. No timing mechanisms are provided to leave the outputs on screen until e.g. a key is pressed. I leave it up to gnuplot_i users to provide that kind of functionality in their own application, depending on the kind of interaction they need. -gnuplot_i is completely free software. Use it for whatever you want to do with it without any fee, and do not hesitate to send feedback to me: +gnuplot_i is completely free software. Use it for whatever you want without any fee, and do not hesitate to send feedback to me: @@ -156,7 +156,7 @@ If you can, I would appreciate a mention somewhere that you are using `gnuplot_i "This software uses the gnuplot_i library written by N.Devillard ." -If you are using gnuplot_i for a web-based application, you can also add a link to the gnuplot home page: +If you are using `gnuplot_i` for a web-based application, you can also add a link to the gnuplot_i home page: http://ndevilla.free.fr/ From 6b9fd66e35d88bf743f4f334db714cbaa2d69e34 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:37:11 +0200 Subject: [PATCH 052/128] Update README.md * Add reference to tutorial --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1c8474b..4f3c610 100644 --- a/README.md +++ b/README.md @@ -81,4 +81,6 @@ Changelog Documentation ------------- +A tutorial is available in `gnuplot_i.md`. + Documentation of macros, includes, functions and prototypes can be straightforwardly generated using [doxygen](https://www.doxygen.nl) and/or the [doxywizard](https://www.doxygen.nl/manual/doxywizard_usage.html). From 33d57ac154468ea805ca193d945513772b3cc2e2 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 14:07:54 +0200 Subject: [PATCH 053/128] Update example.c * Add ASCII-terminal type * Add example with data file: scatter plot --- examples/example.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/examples/example.c b/examples/example.c index 9397f1b..70568cb 100644 --- a/examples/example.c +++ b/examples/example.c @@ -9,7 +9,7 @@ #include #include "gnuplot_i.h" -#define SECONDS 3 +#define SECONDS 2 #define NPOINTS 50 int main(int argc, char *argv[]) { @@ -21,27 +21,34 @@ int main(int argc, char *argv[]) { printf("*** Example of gnuplot control through C ***\n"); h1 = gnuplot_init(); - gnuplot_setterm(h1, "wxt", 900, 400); + + /** Dumb terminal: ASCII-plot, simplest usage of gnuplot_cmd function */ + + printf("\n*** dumb terminal\n"); + gnuplot_setterm(h1, "dumb", 150, 40); + gnuplot_cmd(h1, "plot sin(x) w lines, cos(x) w lines"); /** Equations */ - gnuplot_resetplot(h1); printf("\n*** various equations\n"); + gnuplot_setterm(h1, "wxt", 900, 400); + gnuplot_resetplot(h1); printf("y = sin(x)\n"); gnuplot_plot_equation(h1, "sin(x)", "sine"); sleep(SECONDS); + printf("y = sin(x)*cos(2*x)\n"); + gnuplot_setstyle(h1, "lines"); + gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product"); + sleep(SECONDS); printf("y = 2*x-1\n"); gnuplot_setstyle(h1, "dots"); gnuplot_plot_equation(h1, "2*x-1", "slope"); sleep(SECONDS); - printf("y = sin(x)*cos(2*x)\n"); - gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product"); - sleep(SECONDS); /** Styles */ - gnuplot_resetplot(h1); printf("\n*** showing styles\n"); + gnuplot_resetplot(h1); printf("sine in points\n"); gnuplot_setstyle(h1, "points"); gnuplot_plot_equation(h1, "sin(x)", "sine"); @@ -57,11 +64,11 @@ int main(int argc, char *argv[]) { /** User defined 1d and 2d point sets */ + printf("\n*** user-defined lists of doubles\n"); gnuplot_resetplot(h1); gnuplot_setstyle(h1, "impulses"); gnuplot_set_axislabel(h1, "X", "x"); gnuplot_set_axislabel(h1, "quadratic", "y"); - printf("\n*** user-defined lists of doubles\n"); for (i = 0; i < NPOINTS; i++) { x[i] = (double)i * i; } @@ -79,6 +86,7 @@ int main(int argc, char *argv[]) { /** Splot example */ + printf("\n*** parametric 3D plot\n"); gnuplot_resetplot(h1); gnuplot_setstyle(h1, "lines"); gnuplot_set_axislabel(h1, "X", "x"); @@ -93,6 +101,15 @@ int main(int argc, char *argv[]) { gnuplot_splot(h1, x, y, z, NPOINTS, "Lissajous"); sleep(SECONDS); + /** Scatter plot example, with data file */ + + printf("\n*** scatter plot\n"); + gnuplot_resetplot(h1); + gnuplot_set_axislabel(h1, "avg(mRS)", "x"); + gnuplot_set_axislabel(h1, "alpha", "y"); + gnuplot_cmd(h1, "plot 'scatter.data' with points pointtype '🞄' linecolor 'blue'"); + sleep(SECONDS); + /** Multiple output screens */ printf("\n*** multiple output windows\n"); From 3758869d653bec7d1d3e1f890d6bc1b4a9c03fe8 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Sun, 16 Jul 2023 14:08:18 +0200 Subject: [PATCH 054/128] Add files via upload --- examples/scatter.data | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/scatter.data diff --git a/examples/scatter.data b/examples/scatter.data new file mode 100644 index 0000000..2631764 --- /dev/null +++ b/examples/scatter.data @@ -0,0 +1,20 @@ +0.5482384367480881 11.1285 +0.49539224864150805 6.7712 +0.5608239695103863 2.11495 +0.45976451618541897 0.112346 +0.43009265766396304 0.0882151 +0.5190134596547281 12.2893 +0.5129898986482873 10.8322 +0.5193271503480845 10.6765 +0.4158099648323654 0.221202 +0.4466090499265387 0.151746 +0.5157061254043551 13.1243 +0.5229133895655261 12.1333 +0.5460122532148423 7.92127 +0.5221224362951624 9.05824 +0.4829051648803111 0.514228 +0.5003797594897414 4.64942 +0.5229867730572054 4.23262 +0.5119573706316386 21.8037 +0.5212012129649339 10.8637 +0.5086094337043607 1.64106 From 3fb402e107032def906b0093091535c3615b8b5e Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 18 Jul 2023 18:08:41 +0200 Subject: [PATCH 055/128] Update example.c *Minor updates: style, comments --- examples/example.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/examples/example.c b/examples/example.c index 70568cb..2383542 100644 --- a/examples/example.c +++ b/examples/example.c @@ -2,6 +2,9 @@ * Examples of gnuplot_i.c usage * Compilation: gcc -Wall -g example.c gnuplot_i.c -o example -lm * + * TODO + * - need a test for gnuplot_splot_grid(), gnuplot_contour_plot(), gnuplot_splot_obj(), gnuplot_plot_obj_xy(), gnuplot_plot_once() + * */ #include @@ -22,11 +25,13 @@ int main(int argc, char *argv[]) { printf("*** Example of gnuplot control through C ***\n"); h1 = gnuplot_init(); - /** Dumb terminal: ASCII-plot, simplest usage of gnuplot_cmd function */ + /** Dumb terminal: ASCII-plot */ + /** Simplest usage of gnuplot_cmd function with fewest dependencies */ printf("\n*** dumb terminal\n"); gnuplot_setterm(h1, "dumb", 150, 40); gnuplot_cmd(h1, "plot sin(x) w lines, cos(x) w lines"); + sleep(SECONDS); /** Equations */ @@ -34,15 +39,15 @@ int main(int argc, char *argv[]) { gnuplot_setterm(h1, "wxt", 900, 400); gnuplot_resetplot(h1); printf("y = sin(x)\n"); - gnuplot_plot_equation(h1, "sin(x)", "sine"); + gnuplot_plot_equation(h1, "sin(x)", "sine points"); sleep(SECONDS); printf("y = sin(x)*cos(2*x)\n"); gnuplot_setstyle(h1, "lines"); - gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product"); + gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sines lines"); sleep(SECONDS); printf("y = 2*x-1\n"); gnuplot_setstyle(h1, "dots"); - gnuplot_plot_equation(h1, "2*x-1", "slope"); + gnuplot_plot_equation(h1, "2*x-1", "slope dots"); sleep(SECONDS); /** Styles */ @@ -50,16 +55,16 @@ int main(int argc, char *argv[]) { printf("\n*** showing styles\n"); gnuplot_resetplot(h1); printf("sine in points\n"); - gnuplot_setstyle(h1, "points"); - gnuplot_plot_equation(h1, "sin(x)", "sine"); + gnuplot_setstyle(h1, "linespoints"); + gnuplot_plot_equation(h1, "sin(x)", "sine linespoints"); sleep(SECONDS); printf("sine in impulses\n"); gnuplot_setstyle(h1, "impulses"); - gnuplot_plot_equation(h1, "sin(x)", "sine"); + gnuplot_plot_equation(h1, "sin(x)", "sine impulses"); sleep(SECONDS); printf("arctangens in steps\n"); gnuplot_setstyle(h1, "steps"); - gnuplot_plot_equation(h1, "atan(x)", "arctangens"); + gnuplot_plot_equation(h1, "atan(x)", "arctangens steps"); sleep(SECONDS); /** User defined 1d and 2d point sets */ @@ -67,8 +72,8 @@ int main(int argc, char *argv[]) { printf("\n*** user-defined lists of doubles\n"); gnuplot_resetplot(h1); gnuplot_setstyle(h1, "impulses"); - gnuplot_set_axislabel(h1, "X", "x"); - gnuplot_set_axislabel(h1, "quadratic", "y"); + gnuplot_set_axislabel(h1, "x", "X"); + gnuplot_set_axislabel(h1, "y", "quadratic"); for (i = 0; i < NPOINTS; i++) { x[i] = (double)i * i; } @@ -89,9 +94,9 @@ int main(int argc, char *argv[]) { printf("\n*** parametric 3D plot\n"); gnuplot_resetplot(h1); gnuplot_setstyle(h1, "lines"); - gnuplot_set_axislabel(h1, "X", "x"); - gnuplot_set_axislabel(h1, "Y", "y"); - gnuplot_set_axislabel(h1, "Z-axis", "z"); + gnuplot_set_axislabel(h1, "x", "X"); + gnuplot_set_axislabel(h1, "y", "Y"); + gnuplot_set_axislabel(h1, "z", "Z-axis"); for (int i = 0; i < NPOINTS; i++) { x[i] = 2*sin((double)i/3); y[i] = 5*sin((double)i/2 + 1); @@ -101,12 +106,12 @@ int main(int argc, char *argv[]) { gnuplot_splot(h1, x, y, z, NPOINTS, "Lissajous"); sleep(SECONDS); - /** Scatter plot example, with data file */ + /** Scatter plot: gnuplot example with data file */ printf("\n*** scatter plot\n"); gnuplot_resetplot(h1); - gnuplot_set_axislabel(h1, "avg(mRS)", "x"); - gnuplot_set_axislabel(h1, "alpha", "y"); + gnuplot_set_axislabel(h1, "x", "avg(mRS)"); + gnuplot_set_axislabel(h1, "y", "alpha"); gnuplot_cmd(h1, "plot 'scatter.data' with points pointtype '🞄' linecolor 'blue'"); sleep(SECONDS); From 62b1e52f93ef27473c437619af771bb1beb53a10 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 18 Jul 2023 18:10:32 +0200 Subject: [PATCH 056/128] Update gnuplot_i.c * Code comment updates * Stylistic improvements --- gnuplot_i.c | 51 ++++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/gnuplot_i.c b/gnuplot_i.c index b2916f3..527ece9 100755 --- a/gnuplot_i.c +++ b/gnuplot_i.c @@ -13,6 +13,8 @@ requests to gnuplot through C calls. gnuplot itself is an open source plotting library also written in C. + The plot is displayed in its own window or saved as an image file to disk. + Example of a minimal structure: @code @@ -234,17 +236,16 @@ gnuplot_ctrl *gnuplot_init (void) { @param handle Gnuplot session control handle This is for debugging purposes only. - */ /*--------------------------------------------------------------------------*/ void print_gnuplot_handle (gnuplot_ctrl *handle) { - //fprintf(gnucmd); /*!< Pipe to gnuplot process. */ - printf("Temporary files: %d\n", handle->ntmp); /*!< Number of temporary files in the current session. */ - printf("Active plots: %d\n", handle->nplots); /*!< Number of currently active plots. */ - printf("Plotting style: %s\n", handle->pstyle); /*!< Current plotting style. */ - printf("Terminal name: %s\n", handle->term); /*!< Save terminal name (used by `gnuplot_hardcopy()` function). */ - //char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE]; /*!< Names of temporary files. Only relevant for multiplots */ + //fprintf(gnucmd); /* Pipe to gnuplot process. */ + printf("Temporary files: %d\n", handle->ntmp); /* Number of temporary files in the current session. */ + printf("Active plots: %d\n", handle->nplots); /* Number of currently active plots. */ + printf("Plotting style: %s\n", handle->pstyle); /* Current plotting style. */ + printf("Terminal name: %s\n", handle->term); /* Save terminal name (used by `gnuplot_hardcopy()` function). */ + //char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE]; /* Names of temporary files. Only relevant for multiplots */ return; } @@ -400,12 +401,12 @@ void gnuplot_setterm (gnuplot_ctrl *handle, char *terminal, int width, int heigh Example: @code - gnuplot_set_axislabel(h, "Time(sec)", "x"); + gnuplot_set_axislabel(h, "x", "Time(sec)"); @endcode */ /*--------------------------------------------------------------------------*/ -void gnuplot_set_axislabel (gnuplot_ctrl *handle, char *label, char *axis) { +void gnuplot_set_axislabel (gnuplot_ctrl *handle, char *axis, char *label) { char cmd[GP_CMD_SIZE]; sprintf(cmd, "set %slabel \"%s\"", axis, label); @@ -573,11 +574,11 @@ void gnuplot_plot_xy (gnuplot_ctrl *handle, double *x, double *y, int n, char *t @param title Title of the plot (can be NULL). @return void - Based on `gnuplot_plot_xy`, modifications by Robert Bradley 12/10/2004 - Plots a 3d graph from a list of points, passed as arrays x, y and z. All arrays are assumed to contain the same number of values. + Based on `gnuplot_plot_xy`, modifications by Robert Bradley 12/10/2004 + Example: @code @@ -640,15 +641,15 @@ void gnuplot_splot (gnuplot_ctrl *handle, double *x, double *y, double *z, int n @param title Title of the plot (can be NULL). @return void + Plots a 3d graph from a grid of points, passed in the form of an array [x,y]. + + Based on `gnuplot_splot`, modifications by Robert Bradley 2/4/2006 + Example: @code gnuplot_splot_grid(handle, (double*) points, rows, cols, title); @endcode - - Based on `gnuplot_splot`, modifications by Robert Bradley 2/4/2006 - - Plots a 3d graph from a grid of points, passed in the form of an array [x,y]. */ /*--------------------------------------------------------------------------*/ @@ -701,10 +702,10 @@ void gnuplot_splot_grid (gnuplot_ctrl *handle, double *points, int rows, int col @param title Title of the plot (can be NULL). @return void - Based on `gnuplot_splot`, modifications by Robert Bradley 23/11/2005 - Plots a contour plot from a list of points, passed as arrays x, y and z. + Based on `gnuplot_splot`, modifications by Robert Bradley 23/11/2005 + Example: @code @@ -942,13 +943,9 @@ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, /* Generate commands to send to gnuplot */ gnuplot_setstyle(handle, (style == NULL) ? "lines" : style); - gnuplot_set_axislabel(handle, (label_x == NULL) ? "X" : label_x, "x"); - gnuplot_set_axislabel(handle, (label_y == NULL) ? "Y" : label_y, "y"); - if (y == NULL) { - gnuplot_plot_x(handle, x, n, title); - } else { - gnuplot_plot_xy(handle, x, y, n, title); - } + gnuplot_set_axislabel(handle, "x", (label_x == NULL) ? "X" : label_x); + gnuplot_set_axislabel(handle, "y", (label_y == NULL) ? "Y" : label_y); + (y == NULL) ? gnuplot_plot_x(handle, x, n, title) : gnuplot_plot_xy(handle, x, y, n, title); printf("Press Enter to continue\n"); while (getchar() != '\n') {} gnuplot_close(handle); @@ -962,7 +959,7 @@ void gnuplot_plot_once (char *title, char *style, char *label_x, char *label_y, @param title Title of the plot (can be NULL). @return void - Plots a curve of given equation. The general form of the equation is y=f(x), + Plots a given equation. The general form of the equation is y=f(x), by providing the f(x) side of the equation only. Example: @@ -996,8 +993,8 @@ void gnuplot_plot_equation (gnuplot_ctrl *handle, char *equation, char *title) { @return void Sets the terminal to Postscript, replots the graph and then resets the - terminal back to x11. The use of this function supposes that it will be used - in combination with one of the plotting functions, see example. + terminal back to x11. This function supposes that it will be used in + combination with one of the plotting functions, see example. Example: From ddc37a412fd585ed6a7a248eb0510c4682e2b9f0 Mon Sep 17 00:00:00 2001 From: Long Radix <74498097+longradix@users.noreply.github.com> Date: Tue, 18 Jul 2023 19:31:18 +0200 Subject: [PATCH 057/128] Add files via upload --- Doxyfile | 2662 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2662 insertions(+) create mode 100644 Doxyfile diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..547c55b --- /dev/null +++ b/Doxyfile @@ -0,0 +1,2662 @@ +# Doxyfile 1.9.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "Gnuplot C library interface" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "A gnuplot interface library written in C" + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = images/favicon.ico + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = YES + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = gnuplot_i + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to +# YES then doxygen will add the directory of each input to the include path. +# The default value is: YES. + +CLANG_ADD_INC_PATHS = YES + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = YES + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2 + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /