Skip to main content

Unified scientific charting: scienceplots + a matplotlib-portable Vega-Lite preset

Project description

molcrafts-molplot

Unified scientific charting for the MolCrafts stack — the Python / matplotlib half of MolPlot.

It wraps scienceplots and injects MolPlot's unified preset (palette, type scale, grid, light/dark) so a figure made here matches the same preset rendered in the browser by the TypeScript package @molcrafts/molplot.

The bridge between the two renderers is the Vega-Lite spec — a portable JSON intermediate language. Build a spec in Python and either ship it to the web or render it to matplotlib for a publication figure.

Install

pip install molcrafts-molplot
# optional exact web-parity export (real Vega engine → PNG/SVG):
pip install "molcrafts-molplot[convert]"

Style — scienceplots + unified preset

import matplotlib.pyplot as plt
import molplot

molplot.use("molplot")            # scienceplots base + MolPlot overlay
# or a publication variant (serif, high-DPI, scienceplots 'nature' base):
molplot.use("molplot-paper")

with molplot.style("molplot", mode="dark"):
    plt.plot(x, y)                # scoped; restores rcParams on exit

molplot.palette()[0]              # '#0c5da5' — same categorical colours as the web

plt.style.use("molplot") also works directly (the .mplstyle files are registered on import) — but molplot.use() additionally layers the scienceplots base styles named by the preset.

Charts — one call, or via the portable spec

# one call → (fig, ax)
fig, ax = molplot.line(
    [{"id": "E_total", "x": steps, "y": e_total},
     {"id": "E_kin",   "x": steps, "y": e_kin}],
    x_label="step", y_label="energy (kcal/mol)", show_legend=True,
)

# or build the Vega-Lite spec and choose a renderer:
spec = molplot.scatter_spec(pc1, pc2, color=cluster_id, colorscale="viridis")
fig, ax = molplot.render(spec)     # matplotlib (scienceplots)
molplot.to_png(spec, "fig.png")    # exact web parity via vl-convert (optional)
import json; json.dumps(spec)      # ship the same spec to the browser

line_spec / scatter_spec / bar_spec / gantt_spec emit the same Vega-Lite shapes as the TypeScript @molcrafts/molplot builders.

License

BSD-3-Clause

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

molcrafts_molplot-0.1.2.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

molcrafts_molplot-0.1.2-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file molcrafts_molplot-0.1.2.tar.gz.

File metadata

  • Download URL: molcrafts_molplot-0.1.2.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for molcrafts_molplot-0.1.2.tar.gz
Algorithm Hash digest
SHA256 af46073f4f3f3ce504d3d0c981f46d944bd4d5f4d0269000405a120b98f67a44
MD5 5511fa1cb5364a7fa81c2325fe78a2f9
BLAKE2b-256 e6c4a407147d3ac506d1672eeed7c54ec1117575629a20797cc943632012f406

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molplot-0.1.2.tar.gz:

Publisher: release-python.yml on MolCrafts/molplot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file molcrafts_molplot-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for molcrafts_molplot-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 09e91e2ca274ccf2e2270509ae4852b50defed48d76802d71f8802d92b2a13c7
MD5 a88be865e798b34d5f3feb41629d79f3
BLAKE2b-256 73bce3f92caad6bcc9753d34e8ff8d5065ff8ab72ead8340a2ca1bc2e4159e6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molplot-0.1.2-py3-none-any.whl:

Publisher: release-python.yml on MolCrafts/molplot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page