Skip to main content

vgplot

PyPI

A Python API for authoring Mosaic visualizations. Build declarative, interactive plots backed by DuckDB — in notebooks, as JSON specs, or as part of a data pipeline.

vgplot produces Mosaic View objects that can be rendered with mosaic-widget or exported to JSON for use in a browser. Data sources and parameters defined as local variables are automatically discovered at render time.

Installation

pip install vgplot

To render visualizations in the widget, install the widget:

pip install mosaic-widget

Usage

File-based data

Load data from a file using vg.parquet(), vg.csv(), or vg.table(), pass it directly to a mark, then call view.show() or view:

import vgplot as vg

athletes = vg.parquet("data/athletes.parquet")

view = vg.plot(
    vg.dot(athletes, x="weight", y="height", fill="sex", opacity=0.5),
    vg.width(600),
    vg.height(400),
)

view

Interactive selections

Params and selections are first-class objects. Declare them before the view so they can be referenced by multiple marks or interactors:

import vgplot as vg

flights = vg.parquet("data/flights-200k.parquet")
brush = vg.selection.crossfilter()

view = vg.vconcat(
    vg.plot(
        vg.rect_y(
            flights,
            x=vg.bin("delay"),
            y=vg.count(),
            filter_by=brush,
            fill="steelblue",
            inset_left=0.5,
            inset_right=0.5,
        ),
        vg.interval_x(bind=brush),
        vg.x_domain("Fixed"),
        vg.x_label("Arrival Delay (min)"),
        vg.height(200),
    ),
    vg.plot(
        vg.rect_y(
            flights,
            x=vg.bin("time"),
            y=vg.count(),
            filter_by=brush,
            fill="steelblue",
            inset_left=0.5,
            inset_right=0.5,
        ),
        vg.interval_x(bind=brush),
        vg.x_domain("Fixed"),
        vg.x_label("Departure Time (hour)"),
        vg.height(200),
    ),
)

view

Scalar params and input widgets

Use vg.param() for scalar parameters bound to input controls:

import vgplot as vg

walk = vg.parquet("data/random-walk.parquet")
bias = vg.param(0)

view = vg.vconcat(
    vg.slider(label="Bias", bind=bias, min=0, max=1000, step=1),
    vg.plot(
        vg.area_y(walk, x="t", y=vg.sql("v + $bias")), vg.width(680), vg.height(200)
    ),
)

view

Key concepts

Concept Python API
File-based data vg.parquet(path), vg.csv(path), vg.spatial(path), vg.table(query)
Mark vg.dot(...), vg.bar_y(...), vg.area_y(...), vg.line_y(...), …
Aggregation / transform vg.count(), vg.bin("col"), vg.avg("col"), vg.sum("col"), …
SQL expression vg.sql("expr") — use $param to interpolate a param, e.g. vg.sql("v + $bias")
Plot attributes vg.width(n), vg.height(n), vg.x_label("…"), vg.color_scheme("…"), …
Interactor vg.interval_x(...), vg.interval_xy(...), vg.region(...), vg.highlight(...), …
Layout vg.vconcat(...), vg.hconcat(...), vg.vspace(n), vg.hspace(n)
Crossfilter selection vg.selection.crossfilter()
Intersect / union selection vg.selection.intersect(), vg.selection.union()
Scalar param vg.param(value)
Input widgets vg.slider(...), vg.menu(...), vg.select(...), vg.checkbox(...)
Named data reference vg.source("table_name")
Render view.show() or view as last cell expression in notebooks

Option names match the vgplot API reference, but in snake_case. For example, xDomain → x_domain, colorScheme → color_scheme, filterBy → filter_by.

Any mark or directive not listed above is also accessible by its snake_case name — vg.regression_y(...) and vg.x_tick_rotate(45) work without explicit exports.

Exporting specs

view.to_dict() returns a plain Python dictionary. view.to_json() returns a JSON string:

from pprint import pprint

pprint(view.to_dict())
print(view.to_json(indent=2))

Metadata

Release files for vgplot 0.32.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vgplot 0.32.1
File Size Uploaded
vgplot-0.32.1.tar.gz 27.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vgplot 0.32.1
File Interpreter ABI Platform
vgplot-0.32.1-py3-none-any.whl Python 3 none any Details

Total release size: 53.5 kB

Release files / vgplot-0.32.1.tar.gz

Download URL vgplot-0.32.1.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
72f770845d6f1b6b32fd1251ac65fb0026a029ce3ce55e0e814ed1ec58bba3d4
BLAKE2b-256 checksum
How to use checksums
34d66e1e8ade35eb6a6802e4413079bc708b107574b75893e32fd85405fceaac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / vgplot-0.32.1-py3-none-any.whl

Download URL vgplot-0.32.1-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10d31c4ac8fe86aafcaa3f141b357e0653faf634b8968fd23409391257d31fb1
BLAKE2b-256 checksum
How to use checksums
854034c556d66a6f9493abfd302eb910acd8293b00ef254f282f4a555fdb72f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.32.1 This release

2 release files

0.32.0

2 release files

0.31.0

2 release files

0.29.1

2 release files

0.29.0

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page