Leptonica  1.54
Файл gplot.c
#include <string.h>
#include "allheaders.h"

Функции

GPLOTgplotCreate (const char *rootname, l_int32 outformat, const char *title, const char *xlabel, const char *ylabel)
 
void gplotDestroy (GPLOT **pgplot)
 
l_int32 gplotAddPlot (GPLOT *gplot, NUMA *nax, NUMA *nay, l_int32 plotstyle, const char *plottitle)
 
l_int32 gplotSetScaling (GPLOT *gplot, l_int32 scaling)
 
l_int32 gplotMakeOutput (GPLOT *gplot)
 
l_int32 gplotGenCommandFile (GPLOT *gplot)
 
l_int32 gplotGenDataFiles (GPLOT *gplot)
 
l_int32 gplotSimple1 (NUMA *na, l_int32 outformat, const char *outroot, const char *title)
 
l_int32 gplotSimple2 (NUMA *na1, NUMA *na2, l_int32 outformat, const char *outroot, const char *title)
 
l_int32 gplotSimpleN (NUMAA *naa, l_int32 outformat, const char *outroot, const char *title)
 
l_int32 gplotSimpleXY1 (NUMA *nax, NUMA *nay, l_int32 plotstyle, l_int32 outformat, const char *outroot, const char *title)
 
l_int32 gplotSimpleXY2 (NUMA *nax, NUMA *nay1, NUMA *nay2, l_int32 plotstyle, l_int32 outformat, const char *outroot, const char *title)
 
l_int32 gplotSimpleXYN (NUMA *nax, NUMAA *naay, l_int32 plotstyle, l_int32 outformat, const char *outroot, const char *title)
 
GPLOTgplotRead (const char *filename)
 
l_int32 gplotWrite (const char *filename, GPLOT *gplot)
 

Переменные

static const l_int32 L_BUF_SIZE = 512
 
const char * gplotstylenames []
 
const char * gplotfilestyles []
 
const char * gplotfileoutputs []
 

Функции

◆ gplotAddPlot()

l_int32 gplotAddPlot ( GPLOT gplot,
NUMA nax,
NUMA nay,
l_int32  plotstyle,
const char *  plottitle 
)

gplotAddPlot()

Input:  gplot
        nax (<optional> numa: set to null for Y_VS_I;
             required for Y_VS_X)
        nay (numa: required for both Y_VS_I and Y_VS_X)
        plotstyle (GPLOT_LINES, GPLOT_POINTS, GPLOT_IMPULSES,
                   GPLOT_LINESPOINTS, GPLOT_DOTS)
        plottitle  (<optional> title for individual plot)
Return: 0 if OK, 1 on error

Notes: (1) There are 2 options for (x,y) values: o To plot an array vs a linear function of the index, set nax = NULL. o To plot one array vs another, use both nax and nay. (2) If nax is NULL, the x value corresponding to the i-th value of nay is found from the startx and delx fields in nay: x = startx + i * delx These are set with numaSetParameters(). Their default values are startx = 0.0, delx = 1.0. (3) If nax is defined, it must be the same size as nay. (4) The 'plottitle' string can have spaces, double quotes and backquotes, but not single quotes.

◆ gplotCreate()

GPLOT* gplotCreate ( const char *  rootname,
l_int32  outformat,
const char *  title,
const char *  xlabel,
const char *  ylabel 
)

gplotCreate()

Input:  rootname (root for all output files)
        outformat (GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_X11,
                   GPLOT_LATEX)
        title  (<optional> overall title)
        xlabel (<optional> x axis label)
        ylabel (<optional> y axis label)
Return: gplot, or null on error

Notes: (1) This initializes the plot. (2) The 'title', 'xlabel' and 'ylabel' strings can have spaces, double quotes and backquotes, but not single quotes.

◆ gplotDestroy()

void gplotDestroy ( GPLOT **  pgplot)

gplotDestroy()

 Input: &gplot (<to be nulled>)
 Return: void

◆ gplotGenCommandFile()

l_int32 gplotGenCommandFile ( GPLOT gplot)

gplotGenCommandFile()

Input:  gplot
Return: 0 if OK, 1 on error

◆ gplotGenDataFiles()

l_int32 gplotGenDataFiles ( GPLOT gplot)

gplotGenDataFiles()

Input:  gplot
Return: 0 if OK, 1 on error

◆ gplotMakeOutput()

l_int32 gplotMakeOutput ( GPLOT gplot)

gplotMakeOutput()

Input:  gplot
Return: 0 if OK; 1 on error

Notes: (1) This uses gplot and the new arrays to add a plot to the output, by writing a new data file and appending the appropriate plot commands to the command file. (2) This is the only function in this file that requires the gnuplot executable, to actually generate the plot. (3) The gnuplot program for windows is wgnuplot.exe. The standard gp426win32 distribution does not have a X11 terminal.

◆ gplotRead()

GPLOT* gplotRead ( const char *  filename)

gplotRead()

Input:  filename
Return: gplot, or NULL on error

◆ gplotSetScaling()

l_int32 gplotSetScaling ( GPLOT gplot,
l_int32  scaling 
)

gplotSetScaling()

Input:  gplot
        scaling (GPLOT_LINEAR_SCALE, GPLOT_LOG_SCALE_X,
                 GPLOT_LOG_SCALE_Y, GPLOT_LOG_SCALE_X_Y)
Return: 0 if OK; 1 on error

Notes: (1) By default, the x and y axis scaling is linear. (2) Call this function to set semi-log or log-log scaling.

◆ gplotSimple1()

l_int32 gplotSimple1 ( NUMA na,
l_int32  outformat,
const char *  outroot,
const char *  title 
)

gplotSimple1()

Input:  na (numa; plot Y_VS_I)
        outformat (GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_X11,
                   GPLOT_LATEX)
        outroot (root of output files)
        title  (<optional>, can be NULL)
Return: 0 if OK, 1 on error

Notes: (1) This gives a line plot of a numa, where the array value is plotted vs the array index. The plot is generated in the specified output format; the title is optional. (2) When calling these simple plot functions more than once, use different @outroot to avoid overwriting the output files.

◆ gplotSimple2()

l_int32 gplotSimple2 ( NUMA na1,
NUMA na2,
l_int32  outformat,
const char *  outroot,
const char *  title 
)

gplotSimple2()

Input:  na1 (numa; plotted with Y_VS_I)
        na2 (ditto)
        outformat (GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_X11,
                   GPLOT_LATEX)
        outroot (root of output files)
        title  (<optional>)
Return: 0 if OK, 1 on error

Notes: (1) This gives a line plot of two numa, where the array values are each plotted vs the array index. The plot is generated in the specified output format; the title is optional. (2) When calling these simple plot functions more than once, use different @outroot to avoid overwriting the output files.

◆ gplotSimpleN()

l_int32 gplotSimpleN ( NUMAA naa,
l_int32  outformat,
const char *  outroot,
const char *  title 
)

gplotSimpleN()

Input:  naa (numaa; we plotted with Y_VS_I for each numa)
        outformat (GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_X11,
                   GPLOT_LATEX)
        outroot (root of output files)
        title (<optional>)
Return: 0 if OK, 1 on error

Notes: (1) This gives a line plot of all numas in a numaa (array of numa), where the array values are each plotted vs the array index. The plot is generated in the specified output format; the title is optional. (2) When calling these simple plot functions more than once, use different @outroot to avoid overwriting the output files.

◆ gplotSimpleXY1()

l_int32 gplotSimpleXY1 ( NUMA nax,
NUMA nay,
l_int32  plotstyle,
l_int32  outformat,
const char *  outroot,
const char *  title 
)

gplotSimpleXY1()

Input:  nax (<optional>)
        nay
        plotstyle (GPLOT_LINES, GPLOT_POINTS, GPLOT_IMPULSES,
                   GPLOT_LINESPOINTS, GPLOT_DOTS)
        outformat (GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_X11,
                   GPLOT_LATEX)
        outroot (root of output files)
        title  (<optional>, can be NULL)
Return: 0 if OK, 1 on error

Notes: (1) This gives a plot of a @nay vs @nax, generated in the specified output format. The title is optional. (2) Use 0 for default plotstyle (lines). (3) @nax is optional. If NULL, @nay is plotted against the array index. (4) When calling these simple plot functions more than once, use different @outroot to avoid overwriting the output files.

◆ gplotSimpleXY2()

l_int32 gplotSimpleXY2 ( NUMA nax,
NUMA nay1,
NUMA nay2,
l_int32  plotstyle,
l_int32  outformat,
const char *  outroot,
const char *  title 
)

gplotSimpleXY2()

Input:  nax (<optional; can be NULL)
        nay1
        nay2
        plotstyle (GPLOT_LINES, GPLOT_POINTS, GPLOT_IMPULSES,
                   GPLOT_LINESPOINTS, GPLOT_DOTS)
        outformat (GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_X11,
                   GPLOT_LATEX)
        outroot (root of output files)
        title  (<optional>)
Return: 0 if OK, 1 on error

Notes: (1) This gives plots of @nay1 and @nay2 against nax, generated in the specified output format. The title is optional. (2) Use 0 for default plotstyle (lines). (3) @nax is optional. If NULL, @nay1 and @nay2 are plotted against the array index. (4) When calling these simple plot functions more than once, use different @outroot to avoid overwriting the output files.

◆ gplotSimpleXYN()

l_int32 gplotSimpleXYN ( NUMA nax,
NUMAA naay,
l_int32  plotstyle,
l_int32  outformat,
const char *  outroot,
const char *  title 
)

gplotSimpleXYN()

Input:  nax (<optional>; can be NULL)
        naay (numaa of arrays to plot against @nax)
        plotstyle (GPLOT_LINES, GPLOT_POINTS, GPLOT_IMPULSES,
                   GPLOT_LINESPOINTS, GPLOT_DOTS)
        outformat (GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_X11,
                   GPLOT_LATEX)
        outroot (root of output files)
        title (<optional>)
Return: 0 if OK, 1 on error

Notes: (1) This gives plots of each Numa in @naa against nax, generated in the specified output format. The title is optional. (2) Use 0 for default plotstyle (lines). (3) @nax is optional. If NULL, each Numa array is plotted against the array index. (4) When calling these simple plot functions more than once, use different @outroot to avoid overwriting the output files.

◆ gplotWrite()

l_int32 gplotWrite ( const char *  filename,
GPLOT gplot 
)

gplotWrite()

Input:  filename
        gplot
Return: 0 if OK; 1 on error

Переменные

◆ gplotfileoutputs

const char* gplotfileoutputs[]
Инициализатор
= {"",
"PNG",
"PS",
"EPS",
"X11",
"LATEX"}

◆ gplotfilestyles

const char* gplotfilestyles[]
Инициализатор
= {"LINES",
"POINTS",
"IMPULSES",
"LINESPOINTS",
"DOTS"}

◆ gplotstylenames

const char* gplotstylenames[]
Инициализатор
= {"with lines",
"with points",
"with impulses",
"with linespoints",
"with dots"}

◆ L_BUF_SIZE

const l_int32 L_BUF_SIZE = 512
static