snippets/snippets/series_lines_style.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
//! DO NOT EDIT! This file was autogenerated by `docs/snippets/build.rs`. The original is in `/home/runner/work/rerun/rerun/docs/snippets/all/archetypes/series_lines_style.rs`.
//! Log a scalar over time.
pub fn main(_args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
let rec = rerun::RecordingStreamBuilder::new("rerun_example_series_line_style").spawn()?;
// Set up plot styling:
// They are logged static as they don't change over time and apply to all timelines.
// Log two lines series under a shared root so that they show in the same plot by default.
rec.log_static(
"trig/sin",
&rerun::SeriesLines::new()
.with_colors([[255, 0, 0]])
.with_names(["sin(0.01t)"])
.with_widths([2.0]),
)?;
rec.log_static(
"trig/cos",
&rerun::SeriesLines::new()
.with_colors([[0, 255, 0]])
.with_names(["cos(0.01t)"])
.with_widths([4.0]),
)?;
for t in 0..((std::f32::consts::TAU * 2.0 * 100.0) as i64) {
rec.set_time_sequence("step", t);
// Log two time series under a shared root so that they show in the same plot by default.
rec.log(
"trig/sin",
&rerun::Scalars::single((t as f64 / 100.0).sin()),
)?;
rec.log(
"trig/cos",
&rerun::Scalars::single((t as f64 / 100.0).cos()),
)?;
}
Ok(())
}