Skip to content

Development

Tobias Reiher edited this page Dec 19, 2024 · 2 revisions

Colors

plotters::style::Palette99 includes the following 20 colors:

Palette99

Script to generate the image
use plotters::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let root_drawing_area = SVGBackend::new("palette.svg", (700, 300)).into_drawing_area();
    let child_drawing_areas = root_drawing_area.split_evenly((3, 7));
    for (color, area) in child_drawing_areas.into_iter().enumerate() {
        area.fill(&Palette99::pick(color))?;
        area.draw(&Text::new(
            format!("{color}"),
            (37, 37),
            ("sans-serif", 25.0).into_font(),
        ))?;
    }
    root_drawing_area.present()?;
    Ok(())
}

Charts

To achieve a consistent style, use the following approach:

  • For totals, use area plots. The area has the same color as the line, but with less opacity.
  • For averages, use line plots. For raw values or other additional information, use band plots with the same color as the average, but with less opacity.
Clone this wiki locally