Skip to content

Theme and set_theme

Theme dataclass

Theme(
    base: str = "minimal",
    panel_fill: bool | None = None,
    frame: bool | None = None,
    grid: Grid | None = None,
    grid_opacity: float | None = None,
    axis_lines: Lines | None = None,
    strip_fill: bool | None = None,
    strip_align: Literal["left", "center"] | None = None,
    strip_bold: bool | None = None,
    y_title: Literal["top", "side"] | None = None,
    x_title: Literal["center", "end"] | None = None,
    row_labels: Literal["level", "side"] | None = None,
    panel_gap: int | None = None,
    palette: str | Sequence[str] | None = None,
)

How a plot looks: a named theme's settings, with any of them changed.

at.Theme("minimal", frame=True, panel_gap=12)
at.Theme("classic", palette="petroff10").replace(grid="y")

Parameters:

  • base (str, default: 'minimal' ) –

    The theme it starts from: "minimal", "framed" or "classic".

  • panel_fill (bool | None, default: None ) –

    Fill each panel with a light grey.

  • frame (bool | None, default: None ) –

    A thin line around each panel.

  • grid (Grid | None, default: None ) –

    Which way grid lines run: "auto" (across y, and across x too for points or when y is a category axis), "x", "y", "both" or "none".

  • grid_opacity (float | None, default: None ) –

    The grid: the text colour at this opacity, 0 to 1.

  • axis_lines (Lines | None, default: None ) –

    Which axes draw a line along the panels' edge: "x", "y", "both" or "none".

  • strip_fill (bool | None, default: None ) –

    Strips filled grey; else the label alone, as a title.

  • strip_align (Literal['left', 'center'] | None, default: None ) –

    A strip's label at the "left" or in the "center".

  • strip_bold (bool | None, default: None ) –

    Strip labels semibold.

  • y_title (Literal['top', 'side'] | None, default: None ) –

    The y title level over the plot ("top": ↑ temp) or on its side at its left ("side").

  • x_title (Literal['center', 'end'] | None, default: None ) –

    The x title centred under the plot ("center") or at its right end ("end": weight →).

  • row_labels (Literal['level', 'side'] | None, default: None ) –

    A grid's row labels level at the right, as wide as they need ("level"), or on their side in a strip ("side").

  • panel_gap (int | None, default: None ) –

    Pixels between panels.

  • palette (str | Sequence[str] | None, default: None ) –

    Category colours: a name ("petroff10", "observable10", "tab10", ...) or a list of colours. Trellis(palette=) overrides it.

replace

replace(**changes: Any) -> Theme

This theme with some settings changed.

colors

colors() -> list[str]

Its category colours.

set_theme

set_theme(
    theme: str | Theme = "minimal", **changes: Any
) -> Theme

The theme of every plot made from now on (in this session) without theme=.

at.set_theme("framed")                        # a preset
at.set_theme("minimal", panel_gap=12)         # a preset, changed
at.set_theme()                                # back to the default

get_theme

get_theme() -> Theme

The session's default theme (set_theme).