Skip to content

Commit 7a57d27

Browse files
committed
Python convenience
1 parent 4100124 commit 7a57d27

File tree

3 files changed

+71
-54
lines changed

3 files changed

+71
-54
lines changed

docs/snippets/all/archetypes/scalars_multiple_plots.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717

1818
# NOTE: `SeriesLines` and `SeriesPoints` can both be logged without any associated data
1919
# (all fields are optional). In `v0.24` we removed indicators, which now results in
20-
# no data logged at all, when no fields are specified. Therefore we log a circle shape
21-
# here. More information: https://github.com/rerun-io/rerun/issues/10512
20+
# no data logged at all, when no fields are specified. Therefore, we log a circle shape
21+
# as a marker if no arguments are supplied.
22+
# More information: https://github.com/rerun-io/rerun/issues/10512
2223

2324
# Log scattered points under a different root so that they show in a different plot by default.
24-
rr.log("scatter/lcg", rr.SeriesPoints(markers="circle"), static=True)
25+
rr.log("scatter/lcg", rr.SeriesPoints(), static=True)
2526

2627
# Log the data on a timeline called "step".
2728
for t in range(int(tau * 2 * 100.0)):

rerun_py/rerun_sdk/rerun/archetypes/series_points.py

Lines changed: 3 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
5+
from .. import components, datatypes
6+
7+
from ..error_utils import catch_and_log_exceptions
8+
9+
10+
class SeriesPointsExt:
11+
"""Extension for [SeriesPoints][rerun.archetypes.SeriesPoints]."""
12+
13+
def __init__(
14+
self: Any,
15+
*,
16+
colors: datatypes.Rgba32ArrayLike | None = None,
17+
markers: components.MarkerShapeArrayLike | None = None,
18+
names: datatypes.Utf8ArrayLike | None = None,
19+
visible_series: datatypes.BoolArrayLike | None = None,
20+
marker_sizes: datatypes.Float32ArrayLike | None = None,
21+
) -> None:
22+
"""
23+
Create a new instance of the SeriesPoints archetype.
24+
25+
Parameters
26+
----------
27+
colors:
28+
Color for the corresponding series.
29+
30+
May change over time, but can cause discontinuities in the line.
31+
markers:
32+
What shape to use to represent the point
33+
34+
May change over time.
35+
names:
36+
Display name of the series.
37+
38+
Used in the legend. Expected to be unchanging over time.
39+
visible_series:
40+
Which lines are visible.
41+
42+
If not set, all line series on this entity are visible.
43+
Unlike with the regular visibility property of the entire entity, any series that is hidden
44+
via this property will still be visible in the legend.
45+
46+
May change over time.
47+
marker_sizes:
48+
Sizes of the markers.
49+
50+
May change over time.
51+
52+
"""
53+
54+
# You can define your own __init__ function as a member of SeriesPointsExt in series_points_ext.py
55+
with catch_and_log_exceptions(context=self.__class__.__name__):
56+
57+
if all(arg is None for arg in [colors, markers, names, visible_series, marker_sizes]):
58+
markers = components.MarkerShape.Circle
59+
60+
self.__attrs_init__(
61+
colors=colors, markers=markers, names=names, visible_series=visible_series, marker_sizes=marker_sizes
62+
)
63+
return
64+
self.__attrs_clear__()

0 commit comments

Comments
 (0)