Data Analysis with Rust Notebooks

A practical book on Data Analysis with Rust Notebooks that teaches you the concepts and how they’re implemented in practice.

Get the book

Plotting with Plotters

Plotting with Plotters

I had originally planned to use Plotters for all the graphing in this book. However, shortly after finding Plotters, I found out that a Rust library enabled Plotly support. You will see this in later sections, but for now, here is an example of how Plotters works.

In [2]:
:dep plotters = { git = "", default_features = false, features = ["evcxr", "line_series"] }
extern crate plotters;
use plotters::prelude::*;
use plotters::series::*;

let figure = evcxr_figure((640, 480), |root| {
    let mut chart = ChartBuilder::on(&root)
        .caption("y=x^2", ("Arial", 50).into_font())
        .build_ranged(-1f32..1f32, -0.1f32..1f32)?;


        (-50..=50).map(|x| x as f32 / 50.0).map(|x| (x, x * x)),
        .label("y = x^2")
        .legend(|(x,y)| PathElement::new(vec![(x,y), (x + 20,y)], &RED));


Support this work

You can access this notebook and more by getting the e-book on Data Analysis with Rust Notebooks.