Printing graphs using gnuplot as auxiliary tool
Author(s): David Trallero Mena.This library uses gnuplot for printing graphs.
User-friendly predicates to generate data plots are provided, as well as predicates to set the general options which govern the generation of such plots. If no options is specified, global ones are used for data plots generation.
Several files can be generated as temporary files. A BaseName is required for generating the temporaries files. Data files name will be created from BaseName + number + .dat. The BaseName + ".plot" will be the name used for gnuplot tool.
A list of pairs of list of pairs of the from (X,Y) and Local Option value is provided to the main predicate as data. In other words DataList = [(CurveDataList,LocalOptions), (CurveDataList1,LocalOptions1) ...]. Additionaly (function( String ) , LocalOptions) can be used for adding a curve to the plot (imagine you want to compare your result with 'x=y').
LocalOptions of the DataList are options that are applied to the curve, as for example, if we print the curve with lines, or the title in the legend, etc. GlobalOptions are referred to the plot options, like title in x or y axis, etc.
Usage and interface
- Library usage:
:- use_module(library(gnuplot)). - Exports:
- Predicates:
get_general_options/1, set_general_options/1, generate_plot/2, generate_plot/3.
- Predicates:
- Imports:
Documentation on exports
Usage:get_general_options(X)
Get the general options of the graphic that will be plotted
- The following properties should hold at call time:
(term_typing:var/1)X is a free variable. - The following properties should hold upon exit:
(basic_props:list/1)X is a list.
Usage:set_general_options(X)
Get the general options of the graphic that will be plotted. Possible options are:
- format(A) Specify the format of points
- nokey Legend is no represented
- nogrid No grid
- grid An smooth grid is shown
- label(L , (X,Y)) Put Label L at point (X,Y)
- xlabel(A) Label of X-Axis
- ylabel(A) Label of Y-Axis
- xrange(A,B) Define the X range representation
- yrange(A,B) Define the Y range representation
- title(A) Title of the plot
- key(A) define the key (for example [left,box], left is the position, box indicates that a box should be around)
- term_post(A) define the postscript terminal. A is a list of atoms.
- size(A,B) specify the size of the plot (A,B float numbers)
- autoscale autoscale the size of the plot
- autoscale(A) autoscale the argument (for example: autoscale(x))
- The following properties should hold at call time:
(basic_props:list/1)X is a list.
Usage:generate_plot(BaseName,DataList)
This predicates generate a 'BaseName + .ps' postscript file using each element of DataList as pair of list of pairs and local options, i.e., ( list((X,Y)), LocalOptions), in which X is the position in X-Axis and Y is the position in Y-Axis. Nevertheless, each element of DataList can be a list of pairs instead of a pair for commodity. gnuplot is used as auxiliary tool. Temporary files 'BaseName + N.dat' are generated for for every list of pairs, and 'BaseName + .plot' is de file used by gnuplot. The local options can be:
- with(Option) Tells how the curve will be represented. Option can b line, dots, boxes, impulses, linespoints. This option HAVE TO BE the last one
- title(T) Put the name of the curve in the legend to T
- The following properties should hold at call time:
(term_typing:atom/1)BaseName is currently instantiated to an atom.
(basic_props:list/2)DataList is a list of pairs. - The following properties should hold upon exit:
(term_typing:atom/1)BaseName is currently instantiated to an atom.
(basic_props:list/2)DataList is a list of pairs.
Usage:generate_plot(BaseName,DataList,GeneralOptions)
It is the same as generate_plot/2 but GeneralOptions are used as the general options of the plot. Look at predicate set_general_options for detailed description of possible options
- The following properties should hold at call time:
(term_typing:atom/1)BaseName is currently instantiated to an atom.
(basic_props:list/2)DataList is a list of pairs.
(basic_props:list/1)GeneralOptions is a list. - The following properties should hold upon exit:
(term_typing:atom/1)BaseName is currently instantiated to an atom.
(basic_props:list/2)DataList is a list of pairs.
(basic_props:list/1)GeneralOptions is a list.