From 151f984eff2c77f9a8e22ff1310e52ba692d7bdf Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 6 Feb 2024 11:20:15 +0100 Subject: [PATCH] update examples to use 'name' property of SeriesLine/Point --- .../all/scalar_multiple_plots.cpp | 17 ++++++++++------- .../code-examples/all/scalar_multiple_plots.py | 8 ++++---- .../code-examples/all/scalar_multiple_plots.rs | 18 ++++++++---------- examples/python/plots/main.py | 16 ++++++++-------- tests/rust/plot_dashboard_stress/src/main.rs | 9 --------- 5 files changed, 30 insertions(+), 38 deletions(-) diff --git a/docs/code-examples/all/scalar_multiple_plots.cpp b/docs/code-examples/all/scalar_multiple_plots.cpp index d98aa365736ad..9983ee85a75d1 100644 --- a/docs/code-examples/all/scalar_multiple_plots.cpp +++ b/docs/code-examples/all/scalar_multiple_plots.cpp @@ -15,8 +15,14 @@ int main() { // Set up plot styling: // They are logged timeless 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_timeless("trig/sin", rerun::SeriesLine().with_color({255, 0, 0})); - rec.log_timeless("trig/cos", rerun::SeriesLine().with_color({0, 255, 0})); + rec.log_timeless( + "trig/sin", + rerun::SeriesLine().with_color({255, 0, 0}).with_name("sin(0.01t)") + ); + rec.log_timeless( + "trig/cos", + rerun::SeriesLine().with_color({0, 255, 0}).with_name("cos(0.01t)") + ); // Log scattered points under a different root so that they shows in a different plot by default. rec.log_timeless("scatter/lcg", rerun::SeriesPoint()); @@ -24,11 +30,8 @@ int main() { for (int t = 0; t < static_cast(TAU * 2.0 * 100.0); ++t) { rec.set_time_sequence("step", t); - rec.log("trig/sin", rerun::Scalar(sin(t / 100.0)).with_text("sin(0.01t)")); - rec.log( - "trig/cos", - rerun::Scalar(cos(static_cast(t) / 100.0f)).with_text("cos(0.01t)") - ); + rec.log("trig/sin", rerun::Scalar(sin(t / 100.0))); + rec.log("trig/cos", rerun::Scalar(cos(static_cast(t) / 100.0f))); lcg_state = 1140671485 * lcg_state + 128201163 % 16777216; // simple linear congruency generator diff --git a/docs/code-examples/all/scalar_multiple_plots.py b/docs/code-examples/all/scalar_multiple_plots.py index 1e0095cc650e7..be17908a5427b 100644 --- a/docs/code-examples/all/scalar_multiple_plots.py +++ b/docs/code-examples/all/scalar_multiple_plots.py @@ -11,8 +11,8 @@ # Set up plot styling: # They are logged timeless 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. -rr.log("trig/sin", rr.SeriesLine(color=[255, 0, 0]), timeless=True) -rr.log("trig/cos", rr.SeriesLine(color=[0, 255, 0]), timeless=True) +rr.log("trig/sin", rr.SeriesLine(color=[255, 0, 0], name="sin(0.01t)"), timeless=True) +rr.log("trig/cos", rr.SeriesLine(color=[0, 255, 0], name="cos(0.01t)"), timeless=True) # Log scattered points under a different root so that they shows in a different plot by default. rr.log("scatter/lcg", rr.SeriesPoint(), timeless=True) @@ -20,8 +20,8 @@ for t in range(0, int(tau * 2 * 100.0)): rr.set_time_sequence("step", t) - rr.log("trig/sin", rr.Scalar(sin(float(t) / 100.0), text="sin(0.01t)")) - rr.log("trig/cos", rr.Scalar(cos(float(t) / 100.0), text="cos(0.01t)")) + rr.log("trig/sin", rr.Scalar(sin(float(t) / 100.0))) + rr.log("trig/cos", rr.Scalar(cos(float(t) / 100.0))) lcg_state = (1140671485 * lcg_state + 128201163) % 16777216 # simple linear congruency generator rr.log("scatter/lcg", rr.Scalar(lcg_state)) diff --git a/docs/code-examples/all/scalar_multiple_plots.rs b/docs/code-examples/all/scalar_multiple_plots.rs index 022a171609d30..8e20e20818552 100644 --- a/docs/code-examples/all/scalar_multiple_plots.rs +++ b/docs/code-examples/all/scalar_multiple_plots.rs @@ -9,11 +9,15 @@ fn main() -> Result<(), Box> { // Log two lines series under a shared root so that they show in the same plot by default. rec.log_timeless( "trig/sin", - &rerun::SeriesLine::new().with_color([255, 0, 0]), + &rerun::SeriesLine::new() + .with_color([255, 0, 0]) + .with_name("sin(0.01t)"), )?; rec.log_timeless( "trig/cos", - &rerun::SeriesLine::new().with_color([0, 255, 0]), + &rerun::SeriesLine::new() + .with_color([0, 255, 0]) + .with_name("cos(0.01t)"), )?; // Log scattered points under a different root so that they shows in a different plot by default. rec.log_timeless("scatter/lcg", &rerun::SeriesPoint::new())?; @@ -22,14 +26,8 @@ fn main() -> Result<(), Box> { 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::Scalar::new((t as f64 / 100.0).sin()).with_text("sin(0.01t)"), - )?; - rec.log( - "trig/cos", - &rerun::Scalar::new((t as f64 / 100.0).cos()).with_text("cos(0.01t)"), - )?; + rec.log("trig/sin", &rerun::Scalar::new((t as f64 / 100.0).sin()))?; + rec.log("trig/cos", &rerun::Scalar::new((t as f64 / 100.0).cos()))?; // Log scattered points under a different root so that it shows in a different plot by default. lcg_state = (1140671485_i64 diff --git a/examples/python/plots/main.py b/examples/python/plots/main.py index e1acc9a4e4b30..d352c9926f7db 100755 --- a/examples/python/plots/main.py +++ b/examples/python/plots/main.py @@ -61,6 +61,9 @@ def log_bar_chart() -> None: def log_parabola() -> None: + # Name never changes, log it only once. + rr.log("curves/parabola", rr.SeriesLine(name="f(t) = (0.01t - 3)³ + 1"), timeless=True) + # Log a parabola as a time series for t in range(0, 1000, 10): rr.set_time_sequence("frame_nr", t) @@ -75,27 +78,24 @@ def log_parabola() -> None: rr.log( "curves/parabola", - rr.Scalar( - f_of_t, - text="f(t) = (0.01t - 3)³ + 1", - ), + rr.Scalar(f_of_t), rr.SeriesLine(width=width, color=color), ) def log_trig() -> None: # Styling doesn't change over time, log it once with timeless=True. - rr.log("trig/sin", rr.SeriesLine(color=[255, 0, 0]), timeless=True) - rr.log("trig/cos", rr.SeriesLine(color=[0, 255, 0]), timeless=True) + rr.log("trig/sin", rr.SeriesLine(color=[255, 0, 0], name="sin(0.01t)"), timeless=True) + rr.log("trig/cos", rr.SeriesLine(color=[0, 255, 0], name="cos(0.01t)"), timeless=True) for t in range(0, int(tau * 2 * 1000.0)): rr.set_time_sequence("frame_nr", t) sin_of_t = sin(float(t) / 1000.0) - rr.log("trig/sin", rr.Scalar(sin_of_t, text="sin(0.01t)")) + rr.log("trig/sin", rr.Scalar(sin_of_t)) cos_of_t = cos(float(t) / 1000.0) - rr.log("trig/cos", rr.Scalar(cos_of_t, text="cos(0.01t)")) + rr.log("trig/cos", rr.Scalar(cos_of_t)) def log_classification() -> None: diff --git a/tests/rust/plot_dashboard_stress/src/main.rs b/tests/rust/plot_dashboard_stress/src/main.rs index 9eb8adda20ea9..9c800343f29a8 100644 --- a/tests/rust/plot_dashboard_stress/src/main.rs +++ b/tests/rust/plot_dashboard_stress/src/main.rs @@ -119,15 +119,6 @@ fn run(rec: &rerun::RecordingStream, args: &Args) -> anyhow::Result<()> { let mut tick_start_time = std::time::Instant::now(); - for plot_path in &plot_paths { - for series_path in &series_paths { - rec.log_timeless( - format!("{plot_path}/{series_path}"), - &rerun::SeriesLine::new(), - )?; - } - } - #[allow(clippy::unchecked_duration_subtraction)] for (time_step, sim_time) in sim_times.into_iter().enumerate() { rec.set_time_seconds("sim_time", sim_time);