rustplotlyrust-polars

Secondary y-axis for Plotlars TimeSeriesPlot


I would like to create a Plotlars TimeSeriesPlot for 2 time series that have completely different value range. Hence a secondary y-axis would be great for readability (as of now I just see 2 parallel lines).

But I somehow don't get it to work. There is no pointer in the Plotlars documentation either.

This is the code so far:

use plotlars::{TimeSeriesPlot, Plot};

let df = DataFrame::empty();  // Replace with something more meaningful

TimeSeriesPlot::builder()
   .data(&df)
   .x("our_ts")
   .y("basis_spread")
   .additional_series(vec!["cons_bid"])  // <--- What is missing here to create a 2nd y-axis ?
   .build()
   .write_html("/tmp/line_and_scatter_plot.html");

Solution

  • I’m the maintainer of Plotlars.

    Good news—starting with Plotlars 0.9.0 (just released!) you can add a secondary y-axis to any cartesian plot.