milia.plot.theme#

Lets-plot style: twiga’s theme with the milia palette, replaceable as a whole.

Every lets-plot primitive in milia.plot.lets.draw reads its theme, categorical palette and accent colours from the current Style. A project with its own branding, such as a book, calls use() once and every milia.plot.lets figure then renders in that style:

from milia.plot import theme

theme.use(theme=house_theme, palette=HOUSE_PALETTE, primary="#1E293B")

Functions

color()

Discrete colour scale on the current palette.

current()

The style every lets-plot primitive uses now.

fill()

Discrete fill scale on the current palette.

reset()

Restore the default milia style.

theme(**kwargs)

The current style's lets-plot theme.

twiga(**kwargs)

Twiga's lets-plot theme, the default of Style.

use([style])

Replace the current style, wholly or field by field.

Classes

Style([theme, palette, primary, danger, ...])

Everything a lets-plot primitive needs to look on-brand.

class milia.plot.theme.Style(theme=<function twiga>, palette=<factory>, primary='#107591', danger='#f69a48', highlight='#f69a48', muted='#525252', background='#FFFFFF')#

Bases: object

Everything a lets-plot primitive needs to look on-brand.

Variables:
  • theme (Callable[..., Any]) – Callable returning a lets-plot theme; keyword arguments pass through.

  • palette (Sequence[str]) – Categorical colours, in order.

  • primary (str) – Colour of single-series marks and the high end of a sequential fill.

  • danger (str) – Colour of flagged or out-of-band marks.

  • highlight (str) – Colour of the one group or mark that the reader should notice.

  • muted (str) – Colour of reference lines, labels and secondary marks.

  • background (str) – Colour of tile borders.

Examples

>>> Style(primary="#0369A1").primary
'#0369A1'
theme()#

Twiga’s lets-plot theme, the default of Style.

Parameters:

**kwargs (Any) – Passed to twiga’s twiga_theme, e.g. legend_pos="bottom".

Return type:

Any

Returns:

The lets-plot theme feature.

Examples

>>> twiga() is not None
True
milia.plot.theme.color()#

Discrete colour scale on the current palette.

Return type:

Any

Returns:

A lets-plot scale.

Examples

>>> color() is not None
True
milia.plot.theme.current()#

The style every lets-plot primitive uses now.

Return type:

Style

Returns:

The current Style.

Examples

>>> isinstance(current(), Style)
True
milia.plot.theme.fill()#

Discrete fill scale on the current palette.

Return type:

Any

Returns:

A lets-plot scale.

Examples

>>> fill() is not None
True
milia.plot.theme.reset()#

Restore the default milia style.

Return type:

Style

Returns:

The default Style, now in effect.

Examples

>>> reset().palette == Style().palette
True
milia.plot.theme.theme(**kwargs)#

The current style’s lets-plot theme.

Parameters:

**kwargs (Any) – Passed to the theme callable, e.g. legend_pos="bottom".

Return type:

Any

Returns:

The lets-plot theme feature.

Examples

>>> theme() is not None
True
milia.plot.theme.twiga(**kwargs)#

Twiga’s lets-plot theme, the default of Style.

Parameters:

**kwargs (Any) – Passed to twiga’s twiga_theme, e.g. legend_pos="bottom".

Return type:

Any

Returns:

The lets-plot theme feature.

Examples

>>> twiga() is not None
True
milia.plot.theme.use(style=None, **changes)#

Replace the current style, wholly or field by field.

Parameters:
  • style (Style | None) – A complete style; the current one when omitted.

  • **changes (Any) – Fields of Style to override, e.g. palette=[...].

Return type:

Style

Returns:

The style now in effect.

Examples

>>> use(primary="#1E293B").primary
'#1E293B'
>>> reset() == Style()
True