milia.plot.labels#

Sentence-case labels: every text a figure shows starts with a capital letter.

Figure builders name columns and categories in lower case ("cluster", "member", "silhouette"), and a backend would print those names as they are: as legend titles, legend entries, facet strips and category ticks. capitalised() wraps a drawing primitive so that everything it displays is in sentence case, whichever figure calls it.

Module Attributes

ROLES

Primitive arguments that name a column whose values are shown as text.

AXES

Positional columns whose values become tick labels when they are categorical.

Functions

capital(value)

value with its first character upper-cased, when it is a string.

capitalised(function)

Wrap a drawing primitive so every label it displays is capitalised.

textual(series)

Whether a column holds text, and is therefore displayed as labels.

milia.plot.labels.capital(value)#

value with its first character upper-cased, when it is a string.

Parameters:

value (Any) – Any value; non-strings are returned unchanged.

Return type:

Any

Returns:

The capitalised string, or value.

Names whose case is deliberate, such as "t-SNE" or "fANOVA" (a lower-case letter followed by a capital, directly or after a hyphen), are left unchanged.

Examples

>>> capital("hour of day"), capital("k"), capital(3), capital("t-SNE"), capital("fANOVA")
('Hour of day', 'K', 3, 't-SNE', 'fANOVA')
milia.plot.labels.capitalised(function)#

Wrap a drawing primitive so every label it displays is capitalised.

Axis titles and the figure title are capitalised. A column mapped to colour, fill, facet or group is renamed to its capitalised name, which becomes the legend title, and its text values are capitalised, as are text values on a categorical axis. Palette and width keys follow the renamed values.

Parameters:

function (Callable[..., Any]) – A primitive whose first argument is the data frame.

Return type:

Callable[..., Any]

Returns:

The wrapped primitive.

Examples

>>> @capitalised
... def show(frame, x, y, color=None, xlabel=None):
...     return list(frame.columns), frame[color].tolist(), xlabel
>>> show(pd.DataFrame({"a": [1], "b": [2], "kind": ["mean"]}), "a", "b", color="kind", xlabel="hour")
(['a', 'b', 'Kind'], ['Mean'], 'Hour')