5.7 Module graph.axis.rater: Rater

The rating of axes is implemented in graph.axis.rater. When an axis partitioning scheme returns several partitioning possibilities, the partitions need to be rated by a positive number. The axis partitioning rated lowest is considered best.

The rating consists of two steps. The first takes into account only the number of ticks, subticks, labels and so on in comparison to optimal numbers. Additionally, the extension of the axis range by ticks and labels is taken into account. This rating leads to a preselection of possible partitions. In the second step, after the layout of preferred partitionings has been calculated, the distance of the labels in a partition is taken into account as well at a smaller weight factor by default. Thereby partitions with overlapping labels will be rejected completely. Exceptionally sparse or dense labels will receive a bad rating as well.

class cube( opt, left=None, right=None, weight=1)
Instances of this class provide a number rater. opt is the optimal value. When not provided, left is set to 0 and right is set to 3*opt. Weight is a multiplicator to the result.

The rater calculates width*((x-opt)/(other-opt))**3 to rate the value x, where other is left (x<opt) or right (x>opt).

class distance( opt, weight=0.1)
Instances of this class provide a rater for a list of numbers. The purpose is to rate the distance between label boxes. opt is the optimal value.

The rater calculates the sum of weight*(opt/x-1) (x<opt) or weight*(x/opt-1) (x>opt) for all elements x of the list. It returns this value divided by the number of elements in the list.

class rater( ticks, labels, range, distance)
Instances of this class are raters for axes partitionings.

ticks and labels are both lists of number rater instances, where the first items are used for the number of ticks and labels, the second items are used for the number of subticks (including the ticks) and sublabels (including the labels) and so on until the end of the list is reached or no corresponding ticks are available.

range is a number rater instance which rates the range of the ticks relative to the range of the data.

distance is an distance rater instance.

class linear( ticks=[cube(4), cube(10, weight=0.5)], labels=[cube(4)], range=cube(1, weight=2), distance=distance("1 cm"))
This class is suitable to rate partitionings of linear axes. It is equal to rater but defines predefined values for the arguments.

class lin( ...)
This class is an abbreviation of linear described above.

class logarithmic( ticks=[cube(5, right=20), cube(20, right=100, weight=0.5)], labels=[cube(5, right=20), cube(5, right=20, weight=0.5)], range=cube(1, weight=2), distance=distance("1 cm"))
This class is suitable to rate partitionings of logarithmic axes. It is equal to rater but defines predefined values for the arguments.

class log( ...)
This class is an abbreviation of logarithmic described above.