packages

plot::theme

On this page

Themes: colours, sizes and the colour cycle. light and dark use the Nabi docs site's tokens, so a figure sits on its pages.

Structs

ThemeSource

pub struct Theme

How a figure looks: colours, type sizes, line widths, the series colour cycle and the default colormap. Every field is public; start from light() or dark() and change what you need.

nabi
use plot::Theme;

let t = Theme::dark();
t.font_size = 13.0;
let svg = try plot::line([0.0, 1.0], [1.0, 0.0]).theme(t).svg();
assert(svg.contains("#141114"));
  • pub background: Color§

    Source

    The figure background; transparent to let the page show.

  • pub panel: Color§

    Source

    The plot area background.

  • pub ink: Color§

    Source

    Titles, labels and text.

  • pub ink_muted: Color§

    Source

    Tick labels and legend text.

  • pub axis: Color§

    Source

    Axis lines and ticks.

  • pub grid: Color§

    Source

    Grid lines.

  • pub frame: Color§

    Source

    Legend and colorbar frames.

  • pub font_family: str§

    Source

    The CSS font stack written into SVG output.

  • pub font_size: f64§

    Source

    Tick labels, legend and text, in px.

  • pub label_size: f64§

    Source

    Axis titles, in px.

  • pub title_size: f64§

    Source

    Axes titles, in px.

  • pub line_width: f64§

    Source

    Lines, in px.

  • pub marker_size: f64§

    Source

    Marker diameter, in px.

  • pub axis_width: f64§

    Source

    Axis line width, in px.

  • pub grid_width: f64§

    Source

    Grid line width, in px.

  • pub tick_length: f64§

    Source

    Tick length, in px.

  • pub show_grid: bool§

    Source

    Grid lines at the major ticks.

  • pub box_frame: bool§

    Source

    Draw the top and right axis lines too (a full box).

  • pub cycle: List<Color>§

    Source

    Series colours, used in turn.

  • pub colormap: Colormap§

    Source

    The colormap for heatmaps, contours and colour-by-value.

  • pub fn light() -> Theme§

    Source

    Light: the docs site's light tokens, Okabe-Ito series colours.

    nabi
    assert(plot::Theme::light().show_grid);
    
  • pub fn dark() -> Theme§

    Source

    Dark: the docs site's dark tokens; the cycle's black becomes the ink colour.

    nabi
    assert(plot::Theme::dark().background == plot::Color::rgb(20, 17, 20));
    
  • pub fn transparent(self) -> Theme§

    Source

    The same theme on a transparent background.

    nabi
    assert(plot::Theme::light().transparent().background.a == 0);
    
  • pub fn series(self, i: usize) -> Color§

    Source

    Series colour i, wrapping around the cycle.

    nabi
    assert(plot::Theme::light().series(0) == plot::Color::rgb(0, 114, 178));