Author(s): Isabel Martín García.
Version: 1.11#222 (2004/5/24, 13:8:7 CEST)
Version of last change: 1.9#158 (2003/12/4, 17:39:21 CET)
This module defines predicates which show barchart widgets. The three predicates exported by this module plot two-variable data as regular bars in a window. They all share the following features:
xbarelement2/1 definition type.
xbarelement2/1 type definition. Thus, the user can call each predicate in two ways.
" as the value of the argument.
error2 will be thrown. If the vectors contain elements but are not correct, the exception error1 or error3 will be thrown, depending on the error type. error1 means that XVector and YVector does not contain the same number of elements and error3 indicates that not all the XVector elements contain a correct number of attributes .
Particular features will be pointed out in the corresponding predicate.
genbar2):- use_module(library(genbar2)).
genbar2)
barchart2(Header, BarchartTitle, XTitle, XVector, YTitle, YVector, Footer)
The maximum and minimum limits for axes are determined from the data.
Example:
barchart2('This is the header text',
'Barchart with legend',
'My xaxistitle',
[ [1,'bar1','Blue','Yellow','pattern1'],
[2,'bar2','MediumTurquoise','Plum','pattern5'] ],
'My yaxixtitle',
[20,10],
'This is the footer text').
Usage:
Header is a text (an atom) describing the header of the graph.
(genbar1:header/1)
BarchartTitle is a text (an atom) to be used as label, usually not very long.
(genbar1:title/1)
XTitle is a text (an atom) to be used as label, usually not very long.
(genbar1:title/1)
XVector is a list of xbarelement2s.
(basic_props:list/2)
YTitle is a text (an atom) to be used as label, usually not very long.
(genbar1:title/1)
YVector is a list of yelements.
(basic_props:list/2)
Footer is a text (an atom) describing the footer of the graph.
(genbar1:footer/1)
barchart2(Header, BT, XT, XVector, XMax, XMin, YT, YVector, YMax, YMin, Footer)
You can set the minimum and maximum limits of the axes. Data outside the limits will not be plotted. Each limit, as you can check looking at the
axis_limit/1 definition, is a number. If the argument is a variable the limit will be calculated from the data (i.e., if YMax value is YValueMax the maximum y axis limit will calculated using the largest data value).
Example:
barchart2('This is the header text',
'Barchart with legend',
'My xaxistitle',
[ [1,'bar1',Color1,Color2,Pattern1],
[2,'bar2',Color3,Color4,Pattern2] ],
10,
-10,
'My yaxixtitle',
[20,10],
100,
-10,
'The limits for the axes are set by the user').
Usage:
Header is a text (an atom) describing the header of the graph.
(genbar1:header/1)
BT is a text (an atom) to be used as label, usually not very long.
(genbar1:title/1)
XT is a text (an atom) to be used as label, usually not very long.
(genbar1:title/1)
XVector is a list of xbarelement2s.
(basic_props:list/2)
genbar1:axis_limit(XMax)
(genbar1:axis_limit/1)
genbar1:axis_limit(XMin)
(genbar1:axis_limit/1)
YT is a text (an atom) to be used as label, usually not very long.
(genbar1:title/1)
YVector is a list of yelements.
(basic_props:list/2)
genbar1:axis_limit(YMax)
(genbar1:axis_limit/1)
genbar1:axis_limit(YMin)
(genbar1:axis_limit/1)
Footer is a text (an atom) describing the footer of the graph.
(genbar1:footer/1)
percentbarchart2(Header, BTitle, XTitle, XVector, YTitle, YVector, Footer)
The y axis maximum coordinate value is 100. The x axis limits are autoarrange.
Example:
percentbarchart2('This is a special barchart to represent percentages',
'Barchart with legend',
'My xaxistitle',
[ [1,'bar1','Blue','Yellow','pattern1'],
[2,'bar2','MediumTurquoise','Plum','pattern5'] ],
'My yaxixtitle',
[80,10],
'This is the footer text').
Usage:
Header is a text (an atom) describing the header of the graph.
(genbar1:header/1)
BTitle is a text (an atom) to be used as label, usually not very long.
(genbar1:title/1)
XTitle is a text (an atom) to be used as label, usually not very long.
(genbar1:title/1)
XVector is a list of xbarelement2s.
(basic_props:list/2)
YTitle is a text (an atom) to be used as label, usually not very long.
(genbar1:title/1)
YVector is a list of yelements.
(basic_props:list/2)
Footer is a text (an atom) describing the footer of the graph.
(genbar1:footer/1)
xbarelement2([XValue,LegendElement]) :-
number(XValue),
atomic(LegendElement).
xbarelement2([XValue,LegendElement,ForegColor,BackgColor,SPattern]) :-
number(XValue),
atomic(LegendElement),
color(ForegColor),
color(BackgColor),
pattern(SPattern).
Defines the attributes of the bar.
XValue
LegendElement
LegendElement value of the list must be unique.
ForegColor
BackgColor
SPattern
Go to the first, previous, next, last section, table of contents.