Skip to content

Commit

Permalink
update examples to use 'name' property of SeriesLine/Point
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Feb 6, 2024
1 parent 55ca68a commit 151f984
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 38 deletions.
17 changes: 10 additions & 7 deletions docs/code-examples/all/scalar_multiple_plots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ 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());

// Log the data on a timeline called "step".
for (int t = 0; t < static_cast<int>(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<float>(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<float>(t) / 100.0f)));

lcg_state =
1140671485 * lcg_state + 128201163 % 16777216; // simple linear congruency generator
Expand Down
8 changes: 4 additions & 4 deletions docs/code-examples/all/scalar_multiple_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
# 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)

# Log the data on a timeline called "step".
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))
18 changes: 8 additions & 10 deletions docs/code-examples/all/scalar_multiple_plots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// 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())?;
Expand All @@ -22,14 +26,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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
Expand Down
16 changes: 8 additions & 8 deletions examples/python/plots/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
9 changes: 0 additions & 9 deletions tests/rust/plot_dashboard_stress/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 151f984

Please sign in to comment.