Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utility to rr.components.Color to generate colors from any string (and use it in the air traffic data example) #8458

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Dec 13, 2024

What

It's some time nice to log some color information in multiple entities to make it easier to relate them visually. This PR adds a rr.components.Color.from_str() utility that does exactly that: generate a nice color randomly picked up based on the provided string.

This PR also updates the air traffic data example so the barometric traces have matching colors with the map data.

…ng (and use it in the air traffic data example)
@abey79 abey79 added enhancement New feature or request 🐍 Python API Python logging API include in changelog labels Dec 13, 2024
rerun_py/rerun_sdk/rerun/components/color_ext.py Outdated Show resolved Hide resolved
color = rr.components.Color.from_string(entity_path)
rr.log(
entity_path,
[rr.archetypes.Points3D.indicator(), rr.archetypes.GeoPoints.indicator(), color],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good lord I didnt realize how much that code needs tagged components 🙈

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good example of a component which is intended to be shared across two archetypes, btw. Hopefully we don't make that use case too contrived, aka if that Color is tagged with the Points3D archetype, it should be implicitly(?) used by the GeoPoints archetype as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha yeah I didn't even realize that was what's happening, interesting.

Yeah we'll have to figure out how we want to handle those. I do think heuristics to implicitly pick up the same component from unrelated tags if on the same entity makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vaguely related is one realisation we've had when discussing the archetype vs. visualiser relationship the other day: indicator components are additive, while tags are exclusive. With the former, you could have 2 archetypes with 1 components (e.g. hypothetical ScalarSeriesLine + ScalarSeriesPoint archetypes based on a single scalar component + 2 indicators), but with the latter you are forced to make a choice.

We don't think this constraint is going to be much of problem though. More in #8368

@abey79 abey79 merged commit 4ccfcef into main Dec 16, 2024
31 checks passed
@abey79 abey79 deleted the antoine/color-air-traffic branch December 16, 2024 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request include in changelog 🐍 Python API Python logging API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants