DVC Render

1.0.2 · active · verified Sat Apr 11

dvc-render is a Python library for rendering data stored in DVC plots format into various output formats, such as Vega. It also supports generating HTML and Markdown reports containing multiple plots. It is used internally by DVC, DVCLive, and DVC Studio. The current version is 1.0.2, with frequent patch and minor releases.

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a VegaRenderer instance for a confusion matrix, retrieve its filled Vega-Lite template, and then generate a simple HTML report containing the plot.

from dvc_render import VegaRenderer, render_html

properties = {"template": "confusion", "x": "predicted", "y": "actual"}
datapoints = [
    {"predicted": "B", "actual": "A"},
    {"predicted": "A", "actual": "A"},
    {"predicted": "B", "actual": "B"},
]

# Create a renderer for a single plot
renderer = VegaRenderer(datapoints, "my_confusion_plot", **properties)

# Get the Vega-Lite JSON specification
plot_content = renderer.get_filled_template()
print("Generated Vega-Lite:", plot_content[:100], "...") # Print first 100 chars

# Generate an HTML report with the plot
render_html([renderer], "report.html")
print("Generated report.html")

view raw JSON →