You can define Blueprints in code using the Blueprint API in Python or Rust.
This guide configures the viewport for individual recordings. To configure catalog table columns or embedded segment previews instead, see Configure table layouts and segment previews.
Most of this guide uses Python. For Rust, see Rust Blueprint API below. C++ has no Blueprint API yet, but can load blueprint files. If your blueprint has no effect, see Why is my blueprint ignored?.
Getting started example
This walkthrough demonstrates the Blueprint API using stock market data. We'll start simple and progressively build more complex layouts.
It logs synthetic prices; the blueprint_stocks example fetches real ones from Yahoo Finance.
Setup
First, create a virtual environment and install dependencies:
Linux/Mac:
python -m venv venv
source venv/bin/activate
pip install rerun-sdk numpyWindows:
python -m venv venv
.\venv\Scripts\activate
pip install rerun-sdk numpyBasic script
Create stocks.py, which logs five days of prices for five stocks:
import datetime as dt
import numpy as np
import rerun as rr
import rerun.blueprint as rrb
brand_colors = {
"AAPL": 0xA2AAADFF,
"AMZN": 0xFF9900FF,
"GOOGL": 0x34A853FF,
"META": 0x0081FBFF,
"MSFT": 0xF14F21FF,
}
company_info = {
"AAPL": ("Apple Inc.", "Consumer Electronics"),
"AMZN": ("Amazon.com, Inc.", "Internet Retail"),
"GOOGL": ("Alphabet Inc.", "Internet Content & Information"),
"META": ("Meta Platforms, Inc.", "Internet Content & Information"),
"MSFT": ("Microsoft Corporation", "Software - Infrastructure"),
}
def style_plot(symbol: str) -> rr.SeriesLines:
return rr.SeriesLines(colors=brand_colors[symbol], names=symbol)
def style_peak(symbol: str) -> rr.SeriesPoints:
return rr.SeriesPoints(
colors=0xFF0000FF, names=f"{symbol} (peak)", markers="up"
)
def info_card(symbol: str) -> rr.TextDocument:
name, industry = company_info[symbol]
markdown = f"- **Name**: {name}\n- **Industry**: {industry}\n"
return rr.TextDocument(markdown, media_type=rr.MediaType.MARKDOWN)
symbols = list(brand_colors)
start_date = dt.date(2024, 3, 18)
dates = [start_date + dt.timedelta(days=i) for i in range(5)]
rr.init("rerun_example_blueprint_stocks", spawn=True)
rng = np.random.default_rng(0)
for symbol in symbols:
rr.log(f"stocks/{symbol}/info", info_card(symbol), static=True)
for day in dates:
rr.log(f"stocks/{symbol}/{day}", style_plot(symbol), static=True)
rr.log(f"stocks/{symbol}/peaks/{day}", style_peak(symbol), static=True)
# One price every 5 minutes from market open (9:30) to close (16:00).
prices = 100.0 + np.cumsum(rng.normal(size=78))
peak = int(np.argmax(prices))
for i, price in enumerate(prices):
rr.set_time("time", duration=dt.timedelta(minutes=5 * i))
rr.log(f"stocks/{symbol}/{day}", rr.Scalars(price))
if i == peak:
rr.log(f"stocks/{symbol}/peaks/{day}", rr.Scalars(price))Run the script:
python stocks.pyWithout a blueprint, the heuristic layout may not be ideal:
Creating a simple view
Add a blueprint to the end of the script:
# Create a single chart for all the AAPL data:
blueprint = rrb.Blueprint(
rrb.TimeSeriesView(name="AAPL", origin="/stocks/AAPL"),
)
rr.send_blueprint(blueprint)The origin parameter scopes the view to a specific subtree. Now you'll see just the AAPL data:
Controlling panel state
You can control which panels are visible:
# Create a single chart and collapse the selection and time panels:
blueprint = rrb.Blueprint(
rrb.TimeSeriesView(name="AAPL", origin="/stocks/AAPL"),
rrb.BlueprintPanel(state="expanded"),
rrb.SelectionPanel(state="collapsed"),
rrb.TimePanel(state="collapsed"),
)
rr.send_blueprint(blueprint)
Combining multiple views
Use containers to combine multiple views. The Vertical container stacks views, and row_shares controls relative sizing:
# Create a vertical layout of an info document and a time series chart
blueprint = rrb.Blueprint(
rrb.Vertical(
rrb.TextDocumentView(name="Info", origin="/stocks/AAPL/info"),
rrb.TimeSeriesView(name="Chart", origin="/stocks/AAPL"),
row_shares=[1, 4],
),
rrb.BlueprintPanel(state="expanded"),
rrb.SelectionPanel(state="collapsed"),
rrb.TimePanel(state="collapsed"),
)
rr.send_blueprint(blueprint)
Specifying view contents
The contents parameter provides fine-grained control over what appears in a view. You can include data from multiple sources:
# Create a view with two stock time series
blueprint = rrb.Blueprint(
rrb.TimeSeriesView(
name="META vs MSFT",
contents=[
"+ /stocks/META/2024-03-19",
"+ /stocks/MSFT/2024-03-19",
],
),
rrb.BlueprintPanel(state="expanded"),
rrb.SelectionPanel(state="collapsed"),
rrb.TimePanel(state="collapsed"),
)
rr.send_blueprint(blueprint)
Filtering with expressions
Content expressions can include or exclude subtrees using wildcards. They can reference $origin and use /** to match entire subtrees:
# Create a chart for AAPL and filter out the peaks:
blueprint = rrb.Blueprint(
rrb.TimeSeriesView(
name="AAPL",
origin="/stocks/AAPL",
contents=[
"+ $origin/**",
"- $origin/peaks/**",
],
),
rrb.BlueprintPanel(state="expanded"),
rrb.SelectionPanel(state="collapsed"),
rrb.TimePanel(state="collapsed"),
)
rr.send_blueprint(blueprint)
See Entity path filter for complete expression syntax.
Programmatic layout generation
Since blueprints are Python code, you can generate them dynamically. This example creates a grid with one row per stock symbol:
# Iterate over all symbols and days to create a comprehensive grid
blueprint = rrb.Blueprint(
rrb.Vertical(
contents=[
rrb.Horizontal(
contents=[
rrb.TextDocumentView(
name=f"{symbol}",
origin=f"/stocks/{symbol}/info",
),
]
+ [
rrb.TimeSeriesView(
name=f"{day}",
origin=f"/stocks/{symbol}/{day}",
)
for day in dates
],
name=symbol,
)
for symbol in symbols
]
),
rrb.BlueprintPanel(state="expanded"),
rrb.SelectionPanel(state="collapsed"),
rrb.TimePanel(state="collapsed"),
)
rr.send_blueprint(blueprint)
Saving blueprints from code
You can save programmatically-created blueprints to .rbl files:
"""Craft a blueprint with the python API and save it to file."""
import sys
import rerun.blueprint as rrb
path_to_rbl = sys.argv[1]
blueprint = rrb.Blueprint(
rrb.TimeSeriesView(name="AAPL", origin="/stocks/AAPL"),
)
# Save to a file
blueprint.save("rerun_example_blueprint_stocks", path_to_rbl)
Loading blueprints from any language
Existing blueprint files (e.g. created with the Python SDK or saved from the viewer) can be programmatically loaded into Rerun. This is particularly useful when using the C++ SDK, since the Blueprint API is not available for C++:
"""
Query and display the first 10 rows of a recording in a dataframe view.
The blueprint is being loaded from an existing blueprint recording file.
"""
# python dataframe_view_query_external.py /tmp/dna.rrd /tmp/dna.rbl
import sys
import rerun as rr
path_to_rrd = sys.argv[1]
path_to_rbl = sys.argv[2]
rr.init("rerun_example_dataframe_view_query_external", spawn=True)
rr.log_file_from_path(path_to_rrd)
rr.log_file_from_path(path_to_rbl)
This works using the log_file_from_path API, which allows you to log any file that contains data that Rerun understands — in this case, blueprint data.
API reference:
See the Blueprint API Reference for complete details.
Advanced customization
Each view has its own blueprint properties. For example:
# Configure a 3D view with custom camera settings
robot_view = rrb.Spatial3DView(
name="Robot view",
origin="/world/robot",
background=[100, 149, 237], # Light blue
eye_controls=rrb.EyeControls3D(
kind=rrb.Eye3DKind.FirstPerson,
speed=20.0,
),
)# Configure a time series view with custom axis and time ranges
sensor_view = rrb.TimeSeriesView(
name="Sensor Data",
origin="/sensors",
axis_y=rrb.ScalarAxis(range=(-10.0, 10.0), zoom_lock=True),
plot_legend=rrb.PlotLegend(visible=False),
time_ranges=[
rrb.VisibleTimeRange(
"time",
start=rrb.TimeRangeBoundary.cursor_relative(seconds=-10.0),
end=rrb.TimeRangeBoundary.cursor_relative(),
),
],
)See the view guides, including 3D camera settings and time series axes and ranges. For component defaults and overrides shared by views, see Customize views.
Rust blueprint API
Rust has a builder API in the rerun::blueprint module.
It supports containers (Horizontal, Vertical, Grid, Tabs), all view classes, view origin and contents, component defaults and overrides, and the state of the panels.
Most view-specific properties (for example eye controls or visible time ranges) are only available in Python for now.
This example is adapted from examples/rust/blueprint:
//! Lay out two 2D views in a grid, with per-view contents, defaults, and overrides.
use rerun::blueprint::components::PanelState;
use rerun::blueprint::{
Blueprint, ContainerLike, Grid, SelectionPanel, Spatial2DView,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let blueprint = Blueprint::new(Grid::new(vec![
ContainerLike::from(
Spatial2DView::new("Image and first rect")
.with_origin("/")
.with_contents(["image", "rect/0"]),
),
ContainerLike::from(
Spatial2DView::new("Everything")
.with_origin("/")
.with_contents(["/**"])
.with_defaults(
&rerun::Boxes2D::update_fields().with_radii([2.0]),
)
.with_override(
"rect/0",
&rerun::Boxes2D::update_fields().with_radii([1.0]),
),
),
]))
.with_selection_panel(SelectionPanel::from_state(PanelState::Collapsed));
let rec =
rerun::RecordingStreamBuilder::new("rerun_example_blueprint_grid")
.with_blueprint(blueprint)
.spawn()?;
rec.log(
"rect/0",
&rerun::Boxes2D::from_mins_and_sizes([(16.0, 16.0)], [(64.0, 64.0)]),
)?;
Ok(())
}
with_blueprint makes the blueprint active immediately.
with_default_blueprint only sets it as the default, which the user gets when they reset the blueprint.
To send a blueprint to a stream that already exists, use blueprint.send(&rec, BlueprintActivation { make_active: true, make_default: true }).
Youtube overview
For a video introduction, watch the blueprints overview on YouTube. The code below is a simplified version of the video's example: it sends each blueprint in turn, so running it shows only the last one.
"""Send a series of blueprints that combine many kinds of views in a grid."""
import math
import numpy as np
from numpy.random import default_rng
import rerun as rr
import rerun.blueprint as rrb
rr.init("rerun_example_blueprint_overview", spawn=True)
rr.set_time("time", sequence=0)
rr.log(
"log/status", rr.TextLog("Application started.", level=rr.TextLogLevel.INFO)
)
rr.set_time("time", sequence=5)
rr.log("log/other", rr.TextLog("A warning.", level=rr.TextLogLevel.WARN))
for i in range(10):
rr.set_time("time", sequence=i)
rr.log(
"log/status",
rr.TextLog(f"Processing item {i}.", level=rr.TextLogLevel.INFO),
)
# Create a text view that displays all logs.
blueprint = rrb.Blueprint(
rrb.TextLogView(origin="/log", name="Text Logs"),
rrb.SelectionPanel(state="expanded"),
collapse_panels=True,
)
rr.send_blueprint(blueprint)
# Create a spiral of points:
n = 150
angle = np.linspace(0, 10 * np.pi, n)
spiral_radius = np.linspace(0.0, 3.0, n) ** 2
positions = np.column_stack((
np.cos(angle) * spiral_radius,
np.sin(angle) * spiral_radius,
))
colors = np.dstack((
np.linspace(255, 255, n),
np.linspace(255, 0, n),
np.linspace(0, 255, n),
))[0].astype(int)
radii = np.linspace(0.01, 0.7, n)
rr.log("points", rr.Points2D(positions, colors=colors, radii=radii))
# Create a Spatial2D view to display the points.
blueprint = rrb.Blueprint(
rrb.Spatial2DView(
origin="/",
name="2D Scene",
),
collapse_panels=True,
)
rr.send_blueprint(blueprint)
rr.log(
"points",
rr.GeoPoints(
lat_lon=[[47.6344, 19.1397], [47.6334, 19.1399]],
radii=rr.Radius.ui_points(20.0),
),
)
# Create a map view to display the chart.
blueprint = rrb.Blueprint(
rrb.MapView(
origin="points",
name="MapView",
zoom=16.0,
background=rrb.MapProvider.OpenStreetMap,
),
collapse_panels=True,
)
rr.send_blueprint(blueprint)
blueprint = rrb.Blueprint(
rrb.Grid(
rrb.MapView(
origin="points",
name="MapView",
zoom=16.0,
background=rrb.MapProvider.OpenStreetMap,
),
rrb.Spatial2DView(
origin="/",
name="2D Scene",
),
rrb.TextLogView(origin="/log", name="Text Logs"),
),
rrb.TimePanel(state="expanded"),
rrb.BlueprintPanel(state="expanded"),
collapse_panels=True,
)
rr.send_blueprint(blueprint)
rr.log("bar_chart", rr.BarChart([8, 4, 0, 9, 1, 4, 1, 6, 9, 0]))
rng = default_rng(12345)
positions = rng.uniform(-5, 5, size=[50, 3])
colors = rng.uniform(0, 255, size=[50, 3])
radii = rng.uniform(0.1, 0.5, size=[50])
rr.log("3dpoints", rr.Points3D(positions, colors=colors, radii=radii))
tensor = rng.integers(0, 256, (32, 60, 80, 3), dtype=np.uint8)
rr.log("tensor", rr.Tensor(tensor, dim_names=("batch", "x", "y", "channel")))
rr.log(
"markdown",
rr.TextDocument(
"""
# Hello Markdown!
[Click here to see the raw text](recording://markdown:Text).
"""
),
)
rr.log(
"trig/sin",
rr.SeriesLines(colors=[255, 0, 0], names="sin(0.01t)"),
static=True,
)
for t in range(int(math.pi * 4 * 100.0)):
rr.set_time("time", sequence=t)
rr.set_time("timeline1", duration=t)
rr.log("trig/sin", rr.Scalars(math.sin(float(t) / 100.0)))
blueprint = rrb.Blueprint(
rrb.Grid(
rrb.MapView(
origin="points",
name="MapView",
zoom=16.0,
background=rrb.MapProvider.OpenStreetMap,
),
rrb.Spatial2DView(
origin="/",
name="2D Scene",
),
rrb.TextLogView(origin="/log", name="Text Logs"),
rrb.BarChartView(origin="bar_chart", name="Bar Chart"),
rrb.Spatial3DView(
origin="/3dpoints",
name="3D Scene",
# Set the background color to light blue.
background=[100, 149, 237],
# Configure the eye controls.
eye_controls=rrb.EyeControls3D(
kind=rrb.Eye3DKind.FirstPerson,
speed=20.0,
),
),
rrb.TensorView(
origin="tensor",
name="Tensor",
),
rrb.TextDocumentView(origin="markdown", name="Markdown example"),
rrb.TimeSeriesView(
origin="/trig",
# Set a custom Y axis.
axis_y=rrb.ScalarAxis(range=(-1.0, 1.0), zoom_lock=True),
# Configure the legend.
plot_legend=rrb.PlotLegend(visible=False),
# Set different time ranges for different timelines.
time_ranges=[
# Sliding window around the time cursor on the first timeline.
rrb.VisibleTimeRange(
"time",
start=rrb.TimeRangeBoundary.cursor_relative(seq=-100),
end=rrb.TimeRangeBoundary.cursor_relative(),
),
# From a fixed time to the end of the second timeline.
rrb.VisibleTimeRange(
"timeline1",
start=rrb.TimeRangeBoundary.absolute(seconds=300.0),
end=rrb.TimeRangeBoundary.infinite(),
),
],
),
),
collapse_panels=True,
)
rr.send_blueprint(blueprint)