Author(s): Isabel Martín.
Version: 1.10#7 (2006/4/26, 19:22:13 CEST)
Version of last change: 1.9#265 (2003/12/31, 16:47:45 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').
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').
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').
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.