docs/content/howto/visualization/plot-any-scalar.md
Rerun can plot numerical data as a time series, even data that wasn't logged with Rerun semantics.
By remapping where a visualizer reads its inputs from, you can separate how you model your data from how you visualize it.
This is useful for plotting custom messages from MCAPs, or data logged via AnyValues and DynamicArchetype.
As a bonus, logging multiple scalars to the same entity can drastically reduce .rrd file sizes.
Each visualizer takes components as input and determines their values from various sources. By configuring component mappings, you can control exactly where each input comes from.
The supported data types are:
Float32 and Float64Int8, Int16, Int32, and Int64UInt8, UInt16, UInt32, and UInt64BooleanFor background on how visualizers resolve component values, see Customize views.
Use DynamicArchetype to send data with custom component names alongside regular Rerun data.
Flat arrays and Arrow StructArrays are both supported.
This is what the data looks like for the /plot entity:
snippet: howto/component_mapping[custom_data]
A visualizer can source its inputs from any component with a compatible datatype.
For example, the SeriesLines visualizer accepts any numerical data for its Scalar input.
This works with data from MCAP files, AnyValues, or DynamicArchetype.
Optional components like Names and Colors can be sourced similarly from arbitrary data.
The following remaps the Scalars:scalars input to read from custom:my_custom_scalar instead:
snippet: howto/component_mapping[source_mapping]
When your data lives inside an Arrow StructArray, use a selector to extract a specific field.
Selectors use a jq-inspired syntax (e.g. .values to select the values field).
Data types are automatically cast when compatible. For example, Float32 data will be cast to Float64 as needed by the visualizer.
Here is how to create a nested StructArray:
snippet: howto/component_mapping[nested_struct]
The following remaps the Scalars:scalars input to read from custom:my_nested_scalar and selects the values field:
snippet: howto/component_mapping[selector_mapping]
You can also force a visualizer to use a specific source kind. Setting the source to Default makes the visualizer
ignore any store data and use the view's default instead:
snippet: howto/component_mapping[custom_value]
The complete example logs three series to a single entity and configures each with a different component mapping strategy. This leads to the following visualizers for the /plot entity:
When the view is selected, the selection panel shows an overview of all configured visualizers:
<picture style="zoom: 0.5"> <source media="(max-width: 480px)" srcset="https://static.rerun.io/component-mapping-visualizer-list/48e05924eac3a4a93847299707132c73fe10609c/480w.png"> <source media="(max-width: 768px)" srcset="https://static.rerun.io/component-mapping-visualizer-list/48e05924eac3a4a93847299707132c73fe10609c/768w.png"> <source media="(max-width: 1024px)" srcset="https://static.rerun.io/component-mapping-visualizer-list/48e05924eac3a4a93847299707132c73fe10609c/1024w.png"> </picture>