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.3.tar.gz (19.8 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.3-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: molcrafts_molplot-0.1.3.tar.gz
  • Upload date:
  • Size: 19.8 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.3.tar.gz
Algorithm Hash digest
SHA256 70584f333102234081331a5d0fe0f5a283f495f8b4b703e8f3369295c7bf3b93
MD5 92de9ecfac23a65051b26456a8b4cd60
BLAKE2b-256 f9b541f5b85d6f4f70dbf295cc55c307a4bad8ff508e17b77dfa11007dda6c82

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for molcrafts_molplot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6c4d3783b377dabb8a371b902b9d20b6aa018eea5a2dd4e4d62803ddf23f89a4
MD5 49111726e10e91b98b385d4494c0fab8
BLAKE2b-256 42f88dd0eaca741a7f15bbe709ad45b25203736eea42e0dcede61dace2872d41

See more details on using hashes here.

Provenance

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