An Altair theme and chart utility library for publication-ready scientific figures.
Project description
dysonsphere
dysonsphere is an altair utility library for publication-ready scientific figures in Python, offering:
- An attractive, cohesive, and sensible default configuration with a single invocation of
ds.theme(). - Perceptually uniform palettes, including those from popular data visualization libraries.
- Shareable styles through a simple
dysonsphere.tomlconfig file - tune the theme once and reuse it across projects.
dysonsphere also comes with several intuitive and powerful utilities for altair charts; some highlights include:
- The ability to quickly and easily layer
altaircharts with annotations like reference lines, shades, text, and data labels. - Statistical inference with
scipy, layered directly ontoalt.Chartand conveniently exported as metadata in your saved chart:- Omnibus tests with effect sizes.
- Brackets and p-values for pairwise and post hoc comparisons.
- Correlations with fit lines.
- Multilabels that allow for rich annotations of categorical labels, e.g. multi-condition axes and sample sizes.
- Self-documenting exports for reproducible figures:
ds.save()writes a corrected SVG, print-ready PNG, interactive HTML, and/or Vega-Lite JSON, while also embedding the output file with its provenance: environment versions and sha256 checksums fingerprint both the Vega-Lite spec and the underlying data.ds.read()recovers the statistics report, metadata, and even the original data from a saved figure.ds.load()rebuilds the chart from its JSON.
dysonsphere is extensible: you can develop and install packages of field-specific plotting toolkits (e.g. molecular biology, astronomy) for altair, which plug into the same theme, palettes, and export pipeline that core dysonsphere provides.
Installation
# with pip
pip install dysonsphere
# with uv
uv pip install dysonsphere
# add as a project dependency
uv add dysonsphere
Requires Python 3.11+. Every function that takes a DataFrame accepts polars or pandas.
Dependencies:
altair>=5.5.0numpy>=1.26.0polars[pyarrow]>=1.19.0scipy>=1.11.0vl-convert-python>=1.7.0
Quick start
import altair as alt
import polars as pl
import dysonsphere as ds
ds.theme() # apply the dysonsphere theme to all charts in the session
df = pl.DataFrame({"x": [1.2, 2.4, 3.1, 4.8], "y": [0.9, 2.2, 2.8, 4.4]})
chart = (
alt.Chart(df)
.mark_point()
.encode(
x="x:Q",
y="y:Q",
color=alt.Color("y:Q", scale=alt.Scale(range=ds.palette("blues"))),
)
)
ds.save(chart, "myplot") # writes myplot.svg + myplot.json
Documentation
Documentation, examples, palettes, and an interactive chart studio at dkkung.github.io/dysonsphere
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dysonsphere-3.1.0.tar.gz.
File metadata
- Download URL: dysonsphere-3.1.0.tar.gz
- Upload date:
- Size: 11.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6d3e6280e22ece8ad023d6957759d0ee855d393e673c246b7d1c129cd4ea781
|
|
| MD5 |
c8b93da6e22c70ebbf98b7d08441b89f
|
|
| BLAKE2b-256 |
81641f0f1b1fe61bc1d823ea4892170f32c0f5120c3ee54ac1a2d59c6715c8b6
|
File details
Details for the file dysonsphere-3.1.0-py3-none-any.whl.
File metadata
- Download URL: dysonsphere-3.1.0-py3-none-any.whl
- Upload date:
- Size: 130.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9044efd079a6d66c717e2d0acc404591d04b070c36dd56f7ab1a228b9d777ba1
|
|
| MD5 |
870e45181ff1ed77646dcc0d5833a9f3
|
|
| BLAKE2b-256 |
8b26abe164a868cdabe2cda679b94c1a5f3f3a1fde757687c714ef0f7af5bc34
|