Leptonica 1.68
C Image Processing Library
|
Basic gnuplot-based plotting; serialization of plots. More...
Go to the source code of this file.
Defines | |
#define | L_BUF_SIZE 512 |
#define | MAX_NUM_GPLOTS 40 |
Functions | |
GPLOT * | gplotCreate (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) |
GPLOT * | gplotRead (const char *filename) |
l_int32 | gplotWrite (const char *filename, GPLOT *gplot) |
Variables | |
const char * | gplotstylenames [] |
const char * | gplotfilestyles [] |
const char * | gplotfileoutputs [] |
Basic gnuplot-based plotting; serialization of plots.
Basic plotting functions GPLOT *gplotCreate() void gplotDestroy() l_int32 gplotAddPlot() l_int32 gplotSetScaling() l_int32 gplotMakeOutput() l_int32 gplotGenCommandFile() l_int32 gplotGenDataFiles() Quick and dirty plots l_int32 gplotSimple1() l_int32 gplotSimple2() l_int32 gplotSimpleN() Serialize for I/O GPLOT *gplotRead() l_int32 gplotWrite() Utility for programmatic plotting using gnuplot 7.3.2 or later Enabled: - output to png (color), ps (mono), x11 (color), latex (mono) - optional title for graph - optional x and y axis labels - multiple plots on one frame - optional title for each plot on the frame - optional log scaling on either or both axes - choice of 5 plot styles for each plot - choice of 2 plot modes, either using one input array (Y vs index) or two input arrays (Y vs X). This choice is made implicitly depending on the number of input arrays. Usage: gplotCreate() initializes for plotting gplotAddPlot() for each plot on the frame gplotMakeOutput() to generate all output files and run gnuplot gplotDestroy() to clean up Example of use: gplot = gplotCreate("tempskew", GPLOT_PNG, "Skew score vs angle", "angle (deg)", "score"); gplotAddPlot(gplot, natheta, nascore1, GPLOT_LINES, "plot 1"); gplotAddPlot(gplot, natheta, nascore2, GPLOT_POINTS, "plot 2"); gplotSetScaling(gplot, GPLOT_LOG_SCALE_Y); gplotMakeOutput(gplot); gplotDestroy(&gplot); Note for output to GPLOT_LATEX: This creates latex output of the plot, named <rootname>.tex. It needs to be placed in a latex file <latexname>.tex that precedes the plot output with, at a minimum: \documentclass{article} \begin{document} and ends with \end{document} You can then generate a dvi file <latexname>.dvi using latex <latexname>.tex and a PostScript file <psname>.ps from that using dvips -o <psname>.ps <latexname>.dvi
Definition in file gplot.c.
#define L_BUF_SIZE 512 |
Definition at line 85 of file gplot.c.
Referenced by gplotAddPlot(), gplotCreate(), gplotGenCommandFile(), gplotMakeOutput(), and gplotRead().
GPLOT* gplotCreate | ( | const char * | rootname, |
l_int32 | outformat, | ||
const char * | title, | ||
const char * | xlabel, | ||
const char * | ylabel | ||
) |
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.
Definition at line 126 of file gplot.c.
References buf, CALLOC, GPlot::cmddata, GPlot::cmdname, GPlot::datanames, ERROR_PTR, genPathname(), GPLOT_EPS, GPLOT_LATEX, GPLOT_PNG, GPLOT_PS, GPLOT_X11, L_BUF_SIZE, NULL, numaCreate(), GPlot::outformat, GPlot::outname, GPlot::plotdata, GPlot::plotstyles, GPlot::plottitles, PROCNAME, GPlot::rootname, sarrayCreate(), stringNew(), GPlot::title, GPlot::xlabel, and GPlot::ylabel.
Referenced by GenerateSplitPlot(), gplotRead(), gplotSimple1(), gplotSimple2(), gplotSimpleN(), main(), numaQuantizeCrossingsByWidth(), pixCompareGray(), pixCompareRGB(), pixExtractBarcodeCrossings(), pixFindBaselines(), pixFindSkewSweep(), pixFindSkewSweepAndSearchScorePivot(), pixGetLocalSkewAngles(), pixSplitDistributionFgBg(), and pixWordMaskByDilation().
void gplotDestroy | ( | GPLOT ** | pgplot | ) |
Input: &gplot (<to be="" nulled>="">) Return: void
Definition at line 185 of file gplot.c.
References GPlot::cmddata, GPlot::cmdname, GPlot::datanames, FREE, L_WARNING, NULL, numaDestroy(), GPlot::outname, GPlot::plotdata, GPlot::plotstyles, GPlot::plottitles, PROCNAME, GPlot::rootname, sarrayDestroy(), GPlot::title, GPlot::xlabel, and GPlot::ylabel.
Referenced by GenerateSplitPlot(), gplotSimple1(), gplotSimple2(), gplotSimpleN(), main(), numaQuantizeCrossingsByWidth(), pixCompareGray(), pixCompareRGB(), pixExtractBarcodeCrossings(), pixFindBaselines(), pixFindSkewSweep(), pixFindSkewSweepAndSearchScorePivot(), pixGetLocalSkewAngles(), pixSplitDistributionFgBg(), and pixWordMaskByDilation().
l_int32 gplotAddPlot | ( | GPLOT * | gplot, |
NUMA * | nax, | ||
NUMA * | nay, | ||
l_int32 | plotstyle, | ||
const char * | plottitle | ||
) |
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 the index, set nax = NULL. o To plot one array vs another, use both nax and nay. (2) If nax is defined, it must be the same size as nay. (3) The 'plottitle' string can have spaces, double quotes and backquotes, but not single quotes.
Definition at line 241 of file gplot.c.
References buf, GPlot::datanames, ERROR_INT, GPLOT_DOTS, GPLOT_IMPULSES, GPLOT_LINES, GPLOT_LINESPOINTS, GPLOT_POINTS, L_BUF_SIZE, L_COPY, L_INSERT, GPlot::nplots, numaAddNumber(), numaGetCount(), numaGetFValue(), numaGetXParameters(), GPlot::plotdata, GPlot::plotstyles, GPlot::plottitles, PROCNAME, GPlot::rootname, sarrayAddString(), sarrayCreate(), sarrayDestroy(), sarrayToString(), and stringNew().
Referenced by GenerateSplitPlot(), gplotSimple1(), gplotSimple2(), gplotSimpleN(), main(), numaQuantizeCrossingsByWidth(), pixCompareGray(), pixCompareRGB(), pixExtractBarcodeCrossings(), pixFindBaselines(), pixFindSkewSweep(), pixFindSkewSweepAndSearchScorePivot(), pixGetLocalSkewAngles(), pixSplitDistributionFgBg(), and pixWordMaskByDilation().
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.
Definition at line 318 of file gplot.c.
References ERROR_INT, GPLOT_LINEAR_SCALE, GPLOT_LOG_SCALE_X, GPLOT_LOG_SCALE_X_Y, GPLOT_LOG_SCALE_Y, PROCNAME, and GPlot::scaling.
Referenced by main().
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) The gnuplot program for windows is wgnuplot.exe. The standard gp426win32 distribution does not have a X11 terminal.
Definition at line 349 of file gplot.c.
References buf, GPlot::cmdname, ERROR_INT, GPLOT_X11, gplotGenCommandFile(), gplotGenDataFiles(), L_BUF_SIZE, GPlot::outformat, and PROCNAME.
Referenced by GenerateSplitPlot(), gplotSimple1(), gplotSimple2(), gplotSimpleN(), main(), numaQuantizeCrossingsByWidth(), pixCompareGray(), pixCompareRGB(), pixExtractBarcodeCrossings(), pixFindBaselines(), pixFindSkewSweep(), pixFindSkewSweepAndSearchScorePivot(), pixGetLocalSkewAngles(), pixSplitDistributionFgBg(), and pixWordMaskByDilation().
Input: gplot Return: 0 if OK, 1 on error
Definition at line 387 of file gplot.c.
References buf, GPlot::cmddata, GPlot::cmdname, GPlot::datanames, ERROR_INT, fopenWriteStream(), FREE, GPLOT_EPS, GPLOT_LATEX, GPLOT_LOG_SCALE_X, GPLOT_LOG_SCALE_X_Y, GPLOT_LOG_SCALE_Y, GPLOT_PNG, GPLOT_PS, gplotstylenames, L_BUF_SIZE, L_COPY, L_NOCOPY, NULL, numaGetIValue(), GPlot::outformat, GPlot::outname, GPlot::plotstyles, GPlot::plottitles, PROCNAME, sarrayAddString(), sarrayClear(), sarrayGetCount(), sarrayGetString(), sarrayToString(), GPlot::scaling, GPlot::title, GPlot::xlabel, and GPlot::ylabel.
Referenced by gplotMakeOutput().
Input: gplot Return: 0 if OK, 1 on error
Definition at line 488 of file gplot.c.
References GPlot::datanames, ERROR_INT, fopenWriteStream(), L_NOCOPY, NULL, GPlot::plotdata, PROCNAME, sarrayGetCount(), and sarrayGetString().
Referenced by gplotMakeOutput().
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 this function more than once, be sure the outroot strings are different; otherwise, you will overwrite the output files.
Definition at line 535 of file gplot.c.
References ERROR_INT, GPLOT_EPS, GPLOT_LATEX, GPLOT_LINES, GPLOT_PNG, GPLOT_PS, GPLOT_X11, gplotAddPlot(), gplotCreate(), gplotDestroy(), gplotMakeOutput(), NULL, and PROCNAME.
Referenced by main(), numaSplitDistribution(), pixFindBaselines(), pixGetBinnedColor(), pixGetRankColorArray(), pixPlotAlongPta(), and TestProjection().
l_int32 gplotSimple2 | ( | NUMA * | na1, |
NUMA * | na2, | ||
l_int32 | outformat, | ||
const char * | outroot, | ||
const char * | title | ||
) |
Input: na1 (numa; we plot 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 this function more than once, be sure the outroot strings are different; otherwise, you will overwrite the output files.
Definition at line 582 of file gplot.c.
References ERROR_INT, GPLOT_EPS, GPLOT_LATEX, GPLOT_LINES, GPLOT_PNG, GPLOT_PS, GPLOT_X11, gplotAddPlot(), gplotCreate(), gplotDestroy(), gplotMakeOutput(), NULL, and PROCNAME.
Input: naa (numaa; we plot 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 this function more than once, be sure the outroot strings are different; otherwise, you will overwrite the output files.
Definition at line 631 of file gplot.c.
References ERROR_INT, GPLOT_EPS, GPLOT_LATEX, GPLOT_LINES, GPLOT_PNG, GPLOT_PS, GPLOT_X11, gplotAddPlot(), gplotCreate(), gplotDestroy(), gplotMakeOutput(), L_CLONE, NULL, numaaGetCount(), numaaGetNuma(), numaDestroy(), and PROCNAME.
GPLOT* gplotRead | ( | const char * | filename | ) |
Input: filename Return: gplot, or NULL on error
Definition at line 676 of file gplot.c.
References buf, GPlot::cmddata, GPlot::cmdname, GPlot::datanames, ERROR_PTR, fopenReadStream(), FREE, GPLOT_VERSION_NUMBER, gplotCreate(), L_BUF_SIZE, GPlot::nplots, NULL, numaDestroy(), numaReadStream(), GPlot::outname, GPlot::plotdata, GPlot::plotstyles, GPlot::plottitles, PROCNAME, sarrayDestroy(), sarrayReadStream(), GPlot::scaling, stringNew(), stringReplace(), and version.
Referenced by main().
Input: filename gplot Return: 0 if OK; 1 on error
Definition at line 760 of file gplot.c.
References GPlot::cmddata, GPlot::cmdname, GPlot::datanames, ERROR_INT, fopenWriteStream(), GPLOT_VERSION_NUMBER, GPlot::nplots, NULL, numaWriteStream(), GPlot::outformat, GPlot::outname, GPlot::plotdata, GPlot::plotstyles, GPlot::plottitles, PROCNAME, GPlot::rootname, sarrayWriteStream(), GPlot::scaling, GPlot::title, GPlot::xlabel, and GPlot::ylabel.
Referenced by main().
const char* gplotstylenames[] |
{"with lines", "with points", "with impulses", "with linespoints", "with dots"}
Definition at line 88 of file gplot.c.
Referenced by gplotGenCommandFile().
const char* gplotfilestyles[] |
const char* gplotfileoutputs[] |