Skip to main content

DataFramePlotExt

Trait DataFramePlotExt 

Source
pub trait DataFramePlotExt {
    // Required method
    fn plot(&self) -> DfPlot<'_>;
}
Expand description

Adds a pandas/seaborn-style .plot() accessor to a Polars DataFrame.

The terminal methods return a Figure; save it via the umbrella crate’s FigureExt (use plotkit::prelude::*; then fig.save("out.png")?).

use plotkit_polars::DataFramePlotExt;
use plotkit_polars::polars::prelude::*;

let df = DataFrame::new(vec![
    Series::new("x".into(), &[1.0, 2.0, 3.0]).into(),
    Series::new("y".into(), &[1.0, 4.0, 9.0]).into(),
])
.unwrap();

let fig = df.plot().line("x", "y").unwrap();
assert_eq!(fig.num_axes(), 1);

Required Methods§

Source

fn plot(&self) -> DfPlot<'_>

Begins a plot built directly from this DataFrame’s columns.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl DataFramePlotExt for DataFrame

Source§

fn plot(&self) -> DfPlot<'_>

Implementors§