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]              # '#1f77b4' — 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.1.tar.gz (20.3 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.1-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: molcrafts_molplot-0.1.1.tar.gz
  • Upload date:
  • Size: 20.3 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.1.tar.gz
Algorithm Hash digest
SHA256 f768457e872bcb51c3cf72369a65af8b10e1783d37a04caf6d15370f77198434
MD5 6506091104c66141417bb45fe538e648
BLAKE2b-256 29572df4ca2f685a887f2b77939d1306e6ef4ee9328b3941f65fd2bedebb57b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molplot-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for molcrafts_molplot-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9760e0c551d2d7577ac9dba1956eda04f9450444a962bd729f9c842fb91af1a5
MD5 18508f1be10a5838f144c6549c276898
BLAKE2b-256 dfaa4ce86495c9fe3fc2769b39d4fd1d577af56f74ad97301498e7d02dd673ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molplot-0.1.1-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