https://github.com/daskol/mpl-typst

Typst backend for matplotlib (Python visualization library).

https://github.com/daskol/mpl-typst

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.8%) to scientific vocabulary

Keywords

matplotlib matplotlib-backend mpl typst
Last synced: 5 months ago · JSON representation

Repository

Typst backend for matplotlib (Python visualization library).

Basic Info
  • Host: GitHub
  • Owner: daskol
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 539 KB
Statistics
  • Stars: 44
  • Watchers: 2
  • Forks: 3
  • Open Issues: 8
  • Releases: 2
Topics
matplotlib matplotlib-backend mpl typst
Created about 2 years ago · Last pushed 9 months ago
Metadata Files
Readme Changelog License

README.md

Linting and testing Nightly

Typst Matplotlib Backend

Typst backend for matplotlib (Python visualization library).

Overview

At the moment, Typst supports main vector and raster image formats. Namely, images in PNG, JPEG, GIF, or SVG format can be easily emplaced in a document with Typst. However, it is not possible to keep metadata and annotations. These are mandatory in order to allow a reader to select and interact with vector content (e.g. text) on images. Although SVG can contain text metadata in principle, Typst does not support this feature at the moment but still it is able to render SVG as a vector content.

This package solves this problem for matplotlib users. Basically, this project implements a custom render (or backend) for matplotlib which generates typ-file containing Typst markup. Generated markup file can be later included in the original markup so that the resulting PDF will have interactable content. Matplotlib exploits exactly the same strategy in order to generate PGF-files — a LaTeX markup itself — which can be included into LaTeX markup directly.

Usage

To export a figure using typst, just add

```py import matplotlib import mpl_typst

your drawing code

fig.savefig('figure.typ') ```

You may call plt.show() afterwards, which displays the figure using your default agg backend.

In order to set the mpl_typst module as default backend (which deactivates interactivity, but also renders SVG, PNG and PDF using typst) one can import mpl_typst.as_default module in order to use mpl_typst backend by default.

python import mpl_typst.as_default

Or one can configure it manually.

python import matplotlib as mpl import mpl_typst mpl.use('module://mpl_typst')

Also, it is possible to use rendering context as usual to override backend.

python import matplotlib as mpl import mpl_typst with mpl.rc_context({'backend': 'module://mpl_typst'}): # or mpl_typst.BACKEND ...

Next, you can save your figure to typ as usual.

python fig, ax = plt.subplots() ... fig.savefig('line-plot-simple.typ')

As soon as you get a typ-file you can included it directly to figure function and adjust figure time.

```typst

figure(

include "line-plot-simple.typ", kind: image, caption: [Simple line plot], placement: top, ) ```

GitHub Events

Total
  • Create event: 7
  • Release event: 3
  • Issues event: 14
  • Watch event: 28
  • Delete event: 5
  • Issue comment event: 23
  • Push event: 29
  • Pull request review event: 4
  • Pull request review comment event: 3
  • Pull request event: 14
  • Fork event: 3
Last Year
  • Create event: 7
  • Release event: 3
  • Issues event: 14
  • Watch event: 28
  • Delete event: 5
  • Issue comment event: 23
  • Push event: 29
  • Pull request review event: 4
  • Pull request review comment event: 3
  • Pull request event: 14
  • Fork event: 3

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 24
  • Total Committers: 3
  • Avg Commits per committer: 8.0
  • Development Distribution Score (DDS): 0.208
Past Year
  • Commits: 24
  • Committers: 3
  • Avg Commits per committer: 8.0
  • Development Distribution Score (DDS): 0.208
Top Committers
Name Email Commits
Daniel Bershatsky d****y@g****m 19
Daniel Bershatsky d****l 4
Jonathan Neuhauser j****r@g****e 1
Committer Domains (Top 20 + Academic)
gmx.de: 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 13
  • Total pull requests: 13
  • Average time to close issues: 3 months
  • Average time to close pull requests: 15 days
  • Total issue authors: 7
  • Total pull request authors: 4
  • Average comments per issue: 1.46
  • Average comments per pull request: 1.23
  • Merged pull requests: 12
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 11
  • Pull requests: 12
  • Average time to close issues: 1 day
  • Average time to close pull requests: about 10 hours
  • Issue authors: 5
  • Pull request authors: 4
  • Average comments per issue: 1.55
  • Average comments per pull request: 0.17
  • Merged pull requests: 11
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • cgahr (7)
  • ollelogdahl (1)
  • Conni2461 (1)
  • invenibo (1)
  • JoeJoeTV (1)
Pull Request Authors
  • daskol (9)
  • joneuhauser (3)
  • invenibo (2)
  • theDigitalGuy (1)
Top Labels
Issue Labels
bug (2) good first issue (2) enhancement (2) question (2)
Pull Request Labels
enhancement (8) bug (5) code-quality (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 44 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 7
  • Total maintainers: 1
proxy.golang.org: github.com/daskol/mpl-typst
  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
pypi.org: mpl-typst

Typst backend for matplotlib (Python visualization library).

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 44 Last month
Rankings
Dependent packages count: 10.4%
Average: 34.5%
Dependent repos count: 58.6%
Maintainers (1)
Last synced: 6 months ago