Plot a tradespace
Use the optional visualization package to turn concept summaries into an
interactive chart or a static figure. Get the
downloadable examples, then run
these commands from the folder containing studies/:
python -m pip install "paretorium[visualization]"
python -m studies.visualize_backup
Open runs/workshop-visualization/tradespace.html to see an interactive chart
with concept tooltips, or use tradespace.svg in a report. Both files come
from the same Vega-Lite specification. The HTML bundles its chart runtime.
The example also writes report.html and report.pdf with the chart, table,
and parameter atlas; see Publish a study report.
Make a tradespace from your own results
The snippet uses the workshop study to produce a RunResult. To plot your
own run, substitute your study and result and select its metric IDs
and scenario.
from pathlib import Path
from studies.example_backup import study
from paretorium import summarize
from paretorium.visualization import export_chart, tradespace, tradespace_table
result = study.run(samples=100, seed=42)
summaries = summarize(result.evaluations)
metrics = {metric.id: metric for metric in study.metrics}
comparison = dict(
scenario="long_outage",
x=metrics["cost_usd"],
y=metrics["reserve_wh"],
statistic="p50",
min_feasibility=1.0,
limit_metrics=study.metrics,
)
chart = tradespace(summaries, **comparison)
table = tradespace_table(summaries, **comparison)
export_chart(chart, Path("runs/workshop-comparison"), name="tradespace")
The dots show medians by default. Uncertainty bars are hidden unless you
pass intervals=True to tradespace(). When enabled, they show the
marginal 5th to 95th percentiles of modeled outcomes, not confidence
intervals for the medians or a joint probability region. Thin, dark bars
with end caps are the default style when bars are enabled. A constant
outcome is shown as a dot, with no added cap.
The front uses only the two displayed objectives and excludes concepts
below the feasibility threshold. It can differ from your study's
all-objective Pareto front. The other concepts remain visible. Hover over
a concept or check the companion table to see which metric limits failed
and in how many samples. Pass limit_metrics=study.metrics to show names,
bounds, and units for limits that aren't plotted; otherwise their metric
IDs appear. One sample can fail several limits, so those counts do not
add up to the number of infeasible samples.
The companion Table keeps raw values in rows and display order, labels,
units, and formats in columns. It doesn't impose a page layout or turn
percentages into strings.
Build a metric comparison grid
Pass the (x, y) pairs you want to compare, in reading order. In this
satellite example, both panels put mission cost on the same horizontal
scale. Both utility scores use the full 0–1 range, so their vertical
positions are directly comparable. The satellite module comes from the
same examples download, but it starts a separate study from the workshop
example above.
from dataclasses import replace
from pathlib import Path
from studies.example_satellite import study
from paretorium import summarize
from paretorium.visualization import comparison_grid, export_chart
result = study.run(samples=128, seed=42)
summaries = summarize(result.evaluations)
metrics = {metric.id: metric for metric in study.metrics}
science = replace(metrics["science_value"], objective="max")
operations = replace(metrics["operations_value"], objective="max")
grid = comparison_grid(
summaries,
scenario="nominal",
pairs=((metrics["cost"], science), (metrics["cost"], operations)),
statistic="mean",
min_feasibility=0.9,
color=metrics["power_margin"],
size=metrics["delivered_area"],
label_designs=("D-035", "D-071"),
domains={science.id: (0, 1), operations.id: (0, 1)},
)
export_chart(grid, Path("runs/grid-example"), name="cost-utility")
The two labeled designs stay at the same cost in both panels. Their vertical separation changes when the utility model changes.
Each panel computes its own two-objective front. Setting a direction on
an axis metric here does not change the study objectives. Color and point
area use the same statistic as position and share scales across panels;
neither adds a Pareto objective. If you choose numeric color, shape shows
whether a design is on the front, eligible but dominated, or below the
feasibility threshold. A metric that appears on multiple axes keeps one
range. Pass domains only when you want to override those ranges.
Export the grid as a single chart or wrap it in a Figure for a
report. Use a few panels per figure to keep PDF labels legible.
Label selected designs
Pass label_designs=("D-035", "D-071") to either tradespace() or
comparison_grid(). Canonical concept keys work too; the displayed text
is always the short ID. Labels appear next to the summary dots in SVG, PDF,
and HTML. They are opt-in, so unselected designs still show IDs only in
tooltips. Coincident selected points share a stack of labels; labels on
nearby points can overlap, so select only the designs you want to discuss.
Color by a decision or option pair
Add DecisionColor to a tradespace:
from paretorium.visualization import DecisionColor
chart = tradespace(
summaries,
decision_color=DecisionColor("charger", interactive=True),
**comparison,
)
Use Color by in the interactive HTML to switch which decision
defines the colors. SVG and PDF use the default decision ("charger"
above). Switching colors does not move points, change the feasibility
threshold, or recalculate the front.
Use DecisionColor(("battery", "charger")) for a fixed option-pair
grouping. Add highlight={"charger": "regulated"} to dim the other
concepts and draw a second front for the highlighted subset, using the
same eligibility threshold as the overall front. decision_atlas(...)
generates a report section with one figure per decision; pairs=True
adds a figure for each pair.
Add limits and reference designs
Limits are opt-in. Use overlays=TradespaceOverlays(show_limits=True)
with tradespace() and decision_atlas(), or show_limits=True with
outcome_tradespace() and joint_outcomes(). Each draws dashed
boundaries and shades values outside the displayed metrics' declared
limits. A dashed boundary stops where the other axis already excludes
the region. If neither axis has a bound, no shading is drawn. This is not
a picture of joint feasibility: a concept's median can be in bounds while
some samples or unplotted metrics violate limits.
Add ReferenceDesign("Benchmark", x=570, y=100) to the overlay's
references tuple to mark a point in the chart's units. Reference
designs do not participate in Pareto ranking.
By default, a star marks the utopia point in the chart corner
favored by both objectives. It shows which directions are better,
not a design or a computed objective value. Hide it with
TradespaceOverlays(show_ideal=False).
Inspect individual Monte Carlo outcomes
Pass the raw result.evaluations, not the summaries. Select designs
by their short IDs (e.g. "D-004") or their canonical decision–option
keys. Short IDs are shared by the summary tradespace tooltips,
comparison tables, and outcome plot legends.
from pathlib import Path
from studies.example_backup import study
from paretorium.visualization import export_chart, joint_outcomes, outcome_tradespace
result = study.run(samples=100, seed=42)
metrics = {metric.id: metric for metric in study.metrics}
selected_concept_ids = ("D-004", "D-002")
cloud = outcome_tradespace(
result.evaluations, scenario="long_outage",
x=metrics["cost_usd"], y=metrics["reserve_wh"],
concepts=selected_concept_ids, show_limits=True,
)
joint = joint_outcomes(
result.evaluations, scenario="long_outage",
x=metrics["cost_usd"], y=metrics["reserve_wh"],
concept=selected_concept_ids[0], show_limits=True,
)
output = Path("runs/outcome-example")
export_chart(cloud, output, name="paired-outcomes")
export_chart(joint, output, name="joint-outcomes")
The points for D-004 cross the reserve limit; the points for D-002
stay above it. Cost does not vary within either design.
Each dot contains two outcomes from the same evaluation.
outcome_tradespace() compares selected concepts and adds a marginal
box plot (median, quartiles, and Tukey whiskers) for each.
joint_outcomes() shows one concept with marginal density histograms
and smoothed curves where the data support them. By default, the joint
density contours approximate 50%, 75%, and 90% probability regions.
They are not confidence intervals. The fit needs at least 20 samples,
eight distinct outcomes on each axis, and two-dimensional variation.
For example, a workshop concept's constant cost cannot support a
joint density estimate. The sample dots and histograms remain visible.
Pass probability_levels=() to omit the joint contours explicitly.
Both views show the utopia star in the main scatterplot by default
when both axes specify an objective direction. Pass show_ideal=False
to hide it. For a limit-only metric, you can pass a chart-local copy
such as dataclasses.replace(metric, objective="max") to specify the
preferred direction without changing the study's Pareto objectives.
Compare charts on shared axes
Pass x_domain=(lower, upper) or y_domain=(lower, upper) in metric units
to tradespace(), outcome_tradespace(), or joint_outcomes(). You can
fix either axis and leave the other automatic. For example, pass the same
x_domain=(0, 900) to each workshop chart to compare costs on one scale.
Explicit bounds crop the view. They don't change Pareto ranking, box plot statistics, or density fits. A cropped marginal histogram can have an area less than one: it still normalizes by the total sample count, not just the draws in view. Displayed limit rules outside an explicit range are not drawn.
To build a report section with automatic shared ranges, list the
(scenario, design) pairs to compare. Use result and metrics from the
satellite grid example to show the same
design in two scenarios:
from paretorium.visualization import joint_outcome_atlas
section = joint_outcome_atlas(
result.evaluations,
panels=(("nominal", "D-035"), ("constrained", "D-035")),
x=metrics["power_margin"],
y=metrics["delivered_area"],
show_limits=True,
)
Add the returned section to a report. The atlas includes the selected panels' samples, contour extents, and any enabled limits in its automatic ranges. It also uses identical histogram bins and density scales, so both spread and peaks can be compared across figures. Pass explicit bounds to the atlas to crop every figure to the same region.
Show limits on utility curves
from paretorium.visualization import utility_curve
curve = utility_curve(metrics["power_margin"], domain=(-10, 45), show_limits=True)
Here metrics comes from the satellite grid example.
A utility curve uses the same dashed rules and no-go shading on the input metric axis. This does not alter the utility function, and utility anchors do not count as limits. An explicit domain is kept as given; without one, built-in curves expand their view to include enabled bounds and leave room to see the shaded side.
Style several charts with a theme
Pass the same Theme to views or layers to share their visual style:
from paretorium.visualization import Theme, parameter_atlas
review_theme = Theme(
pareto_color="#6d28d9",
interval_style="plain",
interval_stroke_width=1.25,
stroke_width_scale=1.4,
)
chart = tradespace(summaries, intervals=True, theme=review_theme, **comparison)
atlas = parameter_atlas(study, theme=review_theme)
The theme controls role colors, the category palette, line weights, symbol sizes, and the appearance of interval bars. It does not select the metrics, choose the Pareto front, or turn on the bars. Style is included in the chart specification, so SVG, interactive HTML, and PDF use the same mark styling. Page layout and table formatting are separate.
Compose your own chart from layers
Use the individual components when a built-in view isn't what you need.
Each returns a native Altair layer. You can combine it with other
paretorium layers or with any compatible Altair chart:
import altair as alt
from paretorium.visualization import interval_bars, pareto_front_layer, plot_dots
data = alt.InlineData(values=[
{"cost": 430, "reserve": 130, "low": 95, "high": 155, "charger": "basic"},
{"cost": 570, "reserve": 265, "low": 230, "high": 290, "charger": "regulated"},
])
x = alt.X("cost:Q", title="Cost (USD)")
y = alt.Y("reserve:Q", title="Reserve (Wh)")
# Both example points are nondominated: each offers a different cost/reserve trade.
custom = alt.layer(
interval_bars(
data, x=x, y=alt.Y("low:Q", title="Reserve (Wh)"), end="high",
description="Marginal p05–p95 modeled reserve", theme=review_theme,
),
pareto_front_layer(data, x=x, y=y, theme=review_theme),
plot_dots(
data, x=x, y=y, color="charger", theme=review_theme,
tooltip=(alt.Tooltip("reserve:Q"),),
),
)
Layers draw the data you supply. To show a confidence interval, calculate
its bounds upstream and pass those bounds to interval_bars with a matching
description. To show a projection of an all-objective Pareto front,
select its members upstream and pass connect=False so the projected
points aren't presented as a two-objective frontier.
In the example, color="charger" is a chart decision: charging options
define the series. The theme supplies the colors. Pass an explicit
alt.Color encoding instead if you want to specify a domain, a custom
scale, or quantitative colors. The component leaves explicit encodings
unchanged.
See the visualization API reference for constructor arguments and layer contracts.