github ↗
docs menu

Module Hugin_kit

Visual encoding.

The kit turns data values into the numbers, strings, colours and paths a figure draws, and draws nothing itself. Scale normalises data into [0;1] and gives its guide values, Ticks chooses and labels the ticks of an axis, Number writes numbers, Time puts instants on the calendar and Locale holds the strings numbers and dates are written with. Scheme colours normalised values and categories, Symbol draws marker shapes, Dash breaks lines, Curve draws lines through points, Stack lays lengths end to end and Stats summarises data, as histograms. The kit measures no text: choosing ticks takes a function that measures labels.

Conventions

  • Normalised values. A scale maps its domain onto [0;1], every position a scale or ticks return is such a fraction, and schemes colour such fractions. Points, pixels and projections belong to the figure: curves are drawn in the units of the points they are given, symbols in the units whose square their size is, and stacks in the units of their lengths.
  • Missing values. A value a scale cannot place is missing: Scale.normalize returns nan for it and Scale.invert returns None where no value exists; neither raises. Downstream, Scheme.color paints a normalised nan with the colour given for unknown values, curves break at points with a non-finite coordinate, stacks skip non-finite lengths and histograms count no non-finite value. Functions raise Invalid_argument only on arguments that are programming errors, as each states.
  • Argument order, equality and printing follow hugin.gg: the value a function reads or transforms comes last, equal compares structure with floats compared by Float.equal, and pp output may change between releases unless a printer says otherwise. Functions held by a value, those of a Scale.custom scale, compare physically.
  • Strings. Every string the kit writes is UTF-8 and depends only on the arguments of the call that writes it: there is no global locale, every writer takes a Locale.t that defaults to Locale.default. Digits are the kit's own and the same on every platform (How numbers are written).
  • Typography. Labels use the characters typesetting asks for: U+2212 MINUS SIGN by default, U+00D7 MULTIPLICATION SIGN, the superscript digits and U+207B SUPERSCRIPT MINUS, and U+00B5 MICRO SIGN.
#module Locale : sig ... end

Locales.

#module Number : sig ... end

Number formats.

#module Time : sig ... end

Instants and the calendar.

#module Scale : sig ... end

Scales.

#module Ticks : sig ... end

Axis ticks.

#module Scheme : sig ... end

Colour schemes.

#module Symbol : sig ... end

Symbols.

#module Dash : sig ... end

Dash patterns.

#module Curve : sig ... end

Curves.

#module Stack : sig ... end

Stacks.

#module Stats : sig ... end

Statistics.