bwr-plots is the canonical Blockworks package for branded charts and tables. It is organized around a registry-driven chart API plus explicit feature slices so new chart types, reusable visual features, and standalone table artifacts can be added without editing central dispatch code.
- Each chart lives in its own owned slice under
src/bwr_plots/features/charts. - Each reusable post-render feature lives in its own owned slice under
src/bwr_plots/features/layers. - Standalone branded table rendering lives under
src/bwr_plots/features/tables. - Charts register themselves automatically at import time.
- The canonical API is spec-first:
import pandas as pd
from bwr_plots import render_chart
df = pd.DataFrame(
{"value": [100, 110, 105]},
index=pd.to_datetime(["2026-01-01", "2026-01-02", "2026-01-03"]),
)
fig = render_chart(
df,
{
"kind": "scatter",
"title": "Example chart",
"subtitle": "Registry-driven API",
"source": "Blockworks Research",
"prefix": "$",
},
layers=[
{
"kind": "highlight_bands",
"bands": [
{
"start": "2026-01-02",
"end": "2026-01-03",
"label": "Highlighted window",
}
],
}
],
)The target workflow for teammates is:
- Add one chart slice in
src/bwr_plots/features/charts - Add one test file or extend the chart rendering tests
- Do not edit central chart lists, CLI choices, or registry maps
For reusable features like highlight windows, overlays, or encodings, add a layer file instead of pushing that logic into every chart implementation.
The repo-local authoring guide lives at:
Primary exports from src/bwr_plots/__init__.py:
render_chartrender_chart_artifactlist_chart_typesget_chart_spec_typeget_chart_metadatamake_chart_specmake_layer_specrender_plot_html
Legacy helpers like generate_plot and PlotOptions still exist for transition use, but the package is designed around chart specs and registry discovery now.
Table rendering is a sibling public surface:
render_table_htmlColumnFormatSpec
Example:
import pandas as pd
from bwr_plots import render_table_html
html = render_table_html(
pd.DataFrame({"ticker": ["MSTR"], "nav": [1_234_567]}),
title="Treasury Snapshot",
source_note="Blockworks Research",
column_formats={
"nav": {"kind": "currency", "notation": "compact", "prefix": "$"}
},
)List available charts:
uv run bwr-plots list-chartsRender a chart:
uv run bwr-plots render \
--chart scatter \
--data ./data.csv \
--date-col date \
--output-file ./chart.html \
--spec-json '{"title":"CLI Chart","source":"Blockworks Research"}'Render a table:
uv run bwr-plots render-table \
--data ./table.csv \
--output-file ./table.html \
--title "Treasury Snapshot" \
--source-note "Blockworks Research" \
--column-formats-json '{"nav":{"kind":"currency","notation":"compact","prefix":"$"}}'Default CLI contract:
- chart type via
--chart - structured options via
--spec-jsonor--spec-file - optional layers via
--layers-jsonor--layers-file - table rendering via
render-tablewith--column-formats-jsonor--column-formats-file - generated HTML opens in your default browser unless you pass
--no-open
Local development:
uv sync --group devConsume from another repo with a pinned git tag:
[tool.uv.sources]
bwr-plots = { git = "https://github.com/Blockworks-Projects/bwr-plots.git", tag = "v0.2.5" }src/bwr_plots/api: curated public surfacesrc/bwr_plots/cli: command-line entrypointssrc/bwr_plots/config: presets and defaultssrc/bwr_plots/platform: registry/spec contracts and shared mechanicssrc/bwr_plots/features/charts: per-chart slicessrc/bwr_plots/features/layers: reusable post-render layerssrc/bwr_plots/features/tables: branded Great Tables rendering and artifact assemblysrc/bwr_plots/features/tabular_input: dataframe/file preprocessingdocs/ARCHITECTURE.md: package boundaries and ownershipsrc/bwr_plots/brand-assets: bundled runtime assets
uv run pytest
uv run ruff check .
uv run python -m build