{"id":15613520,"url":"https://github.com/daskol/mpl-typst","last_synced_at":"2025-03-21T08:31:27.557Z","repository":{"id":215181212,"uuid":"738117495","full_name":"daskol/mpl-typst","owner":"daskol","description":"Typst backend for matplotlib (Python visualization library).","archived":false,"fork":false,"pushed_at":"2025-02-23T14:18:59.000Z","size":87,"stargazers_count":25,"open_issues_count":9,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-23T15:24:24.939Z","etag":null,"topics":["matplotlib","matplotlib-backend","mpl","typst"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daskol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-02T13:15:56.000Z","updated_at":"2025-02-23T14:28:56.000Z","dependencies_parsed_at":"2024-10-28T10:14:12.593Z","dependency_job_id":"25df227d-5eb1-4670-9adb-382e038b7bf4","html_url":"https://github.com/daskol/mpl-typst","commit_stats":{"total_commits":24,"total_committers":3,"mean_commits":8.0,"dds":"0.20833333333333337","last_synced_commit":"49357ab103f6c3c0c09498eab09cc962363a6d83"},"previous_names":["daskol/typst-mpl-backend"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskol%2Fmpl-typst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskol%2Fmpl-typst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskol%2Fmpl-typst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskol%2Fmpl-typst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daskol","download_url":"https://codeload.github.com/daskol/mpl-typst/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244765061,"owners_count":20506754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matplotlib","matplotlib-backend","mpl","typst"],"created_at":"2024-10-03T07:01:04.788Z","updated_at":"2025-03-21T08:31:27.550Z","avatar_url":"https://github.com/daskol.png","language":"Python","funding_links":[],"categories":["Integrations \u0026 Tools"],"sub_categories":["Programming"],"readme":"![Linting and testing][1]\n![Nightly][2]\n\n[1]: https://github.com/daskol/typst-mpl-backend/actions/workflows/on-push.yml/badge.svg\n[2]: https://github.com/daskol/typst-mpl-backend/actions/workflows/on-schedule.yml/badge.svg\n\n# Typst Matplotlib Backend\n\n*Typst backend for matplotlib (Python visualization library).*\n\n## Overview\n\nAt the moment, Typst supports main vector and raster image formats. Namely,\nimages in PNG, JPEG, GIF, or SVG format can be easily emplaced in a document\nwith Typst. However, it is **not possible** to keep metadata and annotations.\nThese are mandatory in order to allow a reader to select and interact with\nvector content (e.g. text) on images. Although SVG can contain text metadata in\nprinciple, Typst does not support this feature at the moment but still it is\nable to render SVG as a vector content.\n\nThis package solves this problem for `matplotlib` users. Basically, this\nproject implements a custom render (or backend) for `matplotlib` which\ngenerates `typ`-file containing Typst markup. Generated markup file can be\nlater included in the original markup so that the resulting PDF will have\ninteractable content. Matplotlib exploits exactly the same strategy in order to\ngenerate PGF-files \u0026mdash; a LaTeX markup itself \u0026mdash; which can be included\ninto LaTeX markup directly.\n\n## Usage\n\nTo export a figure using typst, just add\n\n```py\nimport matplotlib\nimport mpl_typst\n\n# your drawing code\n\nfig.savefig('figure.typ')\n```\n\nYou may call `plt.show()` afterwards, which displays the figure using your\ndefault `agg` backend.\n\nIn order to set the `mpl_typst` module as default backend (which deactivates\ninteractivity, but also renders SVG, PNG and PDF using typst) one can import\n`mpl_typst.as_default` module in order to use `mpl_typst` backend by default.\n\n```python\nimport mpl_typst.as_default\n```\n\nOr one can configure it manually.\n\n```python\nimport matplotlib as mpl\nimport mpl_typst\nmpl.use('module://mpl_typst')\n```\n\nAlso, it is possible to use rendering context as usual to override backend.\n\n```python\nimport matplotlib as mpl\nimport mpl_typst\nwith mpl.rc_context({'backend': 'module://mpl_typst'}):  # or mpl_typst.BACKEND\n    ...\n```\n\nNext, you can save your figure to `typ` as usual.\n\n```python\nfig, ax = plt.subplots()\n...\nfig.savefig('line-plot-simple.typ')\n```\n\n\nAs soon as you get a `typ`-file you can included it directly to `figure`\nfunction and adjust figure time.\n\n```typst\n#figure(\n  include \"line-plot-simple.typ\",\n  kind: image,\n  caption: [Simple line plot],\n  placement: top,\n) \u003cline-plot-simple\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaskol%2Fmpl-typst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaskol%2Fmpl-typst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaskol%2Fmpl-typst/lists"}