Skip to main content

scistackplotdb

Plot what's in the database

scistackplotdb loads SciDB variables into the long format scistackplot consumes, and generates pipeline endpoints from a finished plot spec.

pip install scistackplotdb
from scidb import configure_database
from scistackplot import PlotSpec, Role, PlotKind, render
from scistackplotdb import ScidbSource

db = configure_database("experiment.duckdb", ["subject", "session", "trial"])
source = ScidbSource(db)

table = source.get_table(["StepLength"])
spec = PlotSpec(
    measures=["StepLength"],
    roles={"session": Role.GROUP, "subject": Role.COLLAPSE, "trial": Role.COLLAPSE},
    kind=PlotKind.BOX,   # trial averaged within subject; the box is over subjects
)
figure = render(table, spec)

What this layer actually solves

The long format is nearly free — schema keys are already columns once a variable is joined to _schema, the same shape stat_ functions receive. The real work is the four things a flat CSV never had.

Shape classification. Scalar, 1-D, or 2-D, decided from observed values rather than declared SQL type names, and cached. It determines which plot kinds are offered at all.

Joins across schema depth. Plotting trial-level Speed against subject-level Mass broadcasts the shallower variable down the hierarchy:

source.joinable_with("StepLength")     # -> ["Mass"]  (Signal is 1-D: no x axis)
table = source.get_table(["StepLength", "Mass"])   # one Mass value per trial row

Because the dataset schema is an ordered, contiguous hierarchy, one variable's levels are always a prefix of the other's or the two cannot be joined — and join_frames refuses the latter with a message saying why.

Variants are factors — this one is a correctness trap. A variable produced at two filter cutoffs has two records per schema combination. Treating those branch params as ordinary columns silently plots two pipelines' results as if they were replicates of one:

spec = PlotSpec(measures=["Scaled"], roles={"session": Role.GROUP})
complete_roles(spec, table)["scale.factor"]   # Role.ITERATE — one figure per variant, never pooled
validate(spec.with_roles(**{"scale.factor": Role.COLLAPSE}), table)
# RoleError: Variant factor(s) ['scale.factor'] cannot be collapsed: their
# levels are different pipeline variants, not replicates... Give them a
# grouping layer, 'facet' or 'iterate', or select the variant you want with
# PlotSpec.variant_sets.

A transport budget. 1-D data across hundreds of trials is megabytes. resolve(..., max_points=N) downsamples for the interactive panel; export never does.

From spec to pipeline endpoint

from scistackplotdb import generate_endpoint

code = generate_endpoint(spec, table, input_variable="StepLength")
print(code.source)
def plot_steplength(df, filename):
    ...
    return g.figure

for_each(
    plot_steplength,
    inputs={
        "df": StepLength,
        "filename": PathOutput("plots/steplength_{subject}.png"),
    },
    outputs=[StepLengthFigure],
    as_table=['df'],
    finalized=True,
    subject=[],
)

The one translation that has to be exactly right is Role.ITERATE → a for_each iteration keyword. Interactively, ITERATE fans out through a pandas groupby; in the pipeline it fans out through for_each + PathOutput. If those disagree, the exported pipeline is not what you previewed — tests/test_fanout_parity.py runs both paths against the same database and compares the figure sets.

Everything about recording the figure — finalized, artifact stamping, skip_computed, scidb report — is SciDB's existing endpoint machinery and is untouched.

Saved plots

Plot Studio's Saved plots are stored in the project database, so a script can reopen them too:

from scistackplotdb import list_saved_plots, load_saved_plot, save_plot

info = save_plot(db, "StepLength", "Figure 3", spec)       # version 1
save_plot(db, "StepLength", "Figure 3", edited_spec)       # version 2; v1 kept
for plot in list_saved_plots(db, "StepLength"):
    print(plot.name, plot.version, plot.saved_at)

saved = load_saved_plot(db, info.plot_id)                  # newest version
old = load_saved_plot(db, info.plot_id, version=1)
figure = render(ScidbSource(db).get_table(saved.spec.variant_variables()), saved.spec)
  • Append-only. Re-saving a name adds a version. hide_saved_plot removes a plot from the list and deletes nothing.
  • Always written in the current format, read leniently. A plot saved by an older scistackplot still opens; saved.notes lists any setting that no longer applies (scistackplot.restore_spec).
  • Pass table= or table_for= to also check the spec against today's data.

The table, the drift policy and why this is not in the GUI's intent store: docs/claude/saved-plots.md.

Ordering

Factor levels are ordered by SciDB's declared schema_key_types, not by pandas' default: a key declared numeric sorts numerically, and everything else goes through a natural sort so zero-padded IDs land as 01, 02, … 10 instead of 01, 10, 02.

A project that declares its levels ([schema_keys] in scistack.toml, read by scidb.schema_order) wins over both: declared levels first, in that order, the rest after them by the rule above. The declaration is read live, and a change drops the source's built tables, so an edit shows on the next plot request. Exported seaborn code states every order it relies on (order=, hue_order=, col_order=, row_order=) rather than leaving seaborn to use the frame's row order.

See docs/claude/plotting-library-design.md and the [schema_keys] section of docs/claude/config-file-formats.md.

Metadata

Release files for scistackplotdb 0.1.51

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

Source distribution (sdist)

Source distribution for scistackplotdb 0.1.51
File Size Uploaded Provenance
scistackplotdb-0.1.51.tar.gz 69.3 kB With provenance Details

Built distribution (wheel)

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

Total release size: 145.3 kB

Release files / scistackplotdb-0.1.51.tar.gz

Download URL scistackplotdb-0.1.51.tar.gz
Size 69.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b5d8c7ae6cebcf55380dea029cc1cde1e27efb62459a5f2666bd95ea8061c2b3
BLAKE2b-256 checksum
How to use checksums
553fa25343cb9b55555c5a11ff827546f098581fa4d74f29e79aeda67c2eb1be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 21, 2026.

Transparency log

Release files / scistackplotdb-0.1.51-py3-none-any.whl

Download URL scistackplotdb-0.1.51-py3-none-any.whl
Size 76.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1bcf420b519abc5bc585e20644fddb81e0b6ad24d1abf8c509451b2caa6e2a9d
BLAKE2b-256 checksum
How to use checksums
c2b7f6d7a44be0b47bc637f34d4c6322ec9e9e43a4f4759486f4b6b6d032fc68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 21, 2026.

Transparency log

Security for scistackplotdb 0.1.51

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for scistackplotdb-0.1.51.tar.gz

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 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

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