Documentation
¶
Overview ¶
A very simple library that aids in creating plots with gnuplot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // The regex that matches strings that need to be replaced in the supplied // cmds. The exact contents of the string found by the regular expression // will determine what it is replaced with. OpRegex = regexp.MustCompile("\\${[^{]*}") InvalidOpErr = errors.New("Invalid op") InvalidDatOpErr = errors.New("Invalid dat op") InvalidDatIndexErr = errors.New("Invalid data index") )
Functions ¶
This section is empty.
Types ¶
type GnuPlot ¶
type GnuPlot struct {
// contains filtered or unexported fields
}
The main struct that is used to control plot generation.
func NewGnuPlot ¶
func NewGnuPlot(opts GnuPlotOpts) (GnuPlot, error)
Creates a new GnuPlot struct with the supplied options. All data and gnu plot code files will be created. The output file will be created by gnu plot itself when the GnuPlot.Run method is called.
func (*GnuPlot) Cmds ¶
Writes cmds to the gnu plot code file. The cmds will be parsed for operations. An operation will replace the given text with a specific value. Valid operations are as follows:
- {out}: Replaces `{out}` with the path of the out file
- {dat:#}: Replaces `{dat:#}` with the path of the data file at the index specified by `#`. If `#` is not a valid number, a negative number, or a number outside the range of the data file list an error will be returned and none of the supplied cmds will be added
func (*GnuPlot) DataRow ¶
Writes a data row to the data file specified by the `file` index. If the index specified by `file` is invalid a InvalidDatIndexErr will be returned.
To write an empty line call this method with a single empty string as the data arguments.
If no data arguments are provided no work will be done and no error will be returned.
type GnuPlotOpts ¶
type GnuPlotOpts struct { // Specifies the file where the generated gnuplot code will go. This // path will be relative to the current directory. GpltFile string // Specifies the files where the data for the plot will be written to. // The order of the files matters because methods on [GnuPlot] will // reference a data file by index. // All paths will be relative to the current directory. DatFiles []string // Specifies the file where the generated plot will be written to. This // path will be relative to the current directory. OutFile string // The column delimiter character that should be used when writing the // data to the dat files. CsvSep rune }