{"id":13676008,"url":"https://github.com/nschloe/tikzplotlib","last_synced_at":"2026-04-01T20:44:28.767Z","repository":{"id":780314,"uuid":"472623","full_name":"nschloe/tikzplotlib","owner":"nschloe","description":":bar_chart: Save matplotlib figures as TikZ/PGFplots for smooth integration into LaTeX.","archived":false,"fork":false,"pushed_at":"2024-08-16T05:00:45.000Z","size":2791,"stargazers_count":2566,"open_issues_count":137,"forks_count":245,"subscribers_count":45,"default_branch":"main","last_synced_at":"2026-03-08T07:40:32.609Z","etag":null,"topics":["latex","matplotlib","pgfplots","python","tikz"],"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/nschloe.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},"funding":{"github":"nschloe","ko-fi":"nschloe"}},"created_at":"2010-01-14T21:44:27.000Z","updated_at":"2026-03-06T14:05:22.000Z","dependencies_parsed_at":"2024-11-19T02:15:30.160Z","dependency_job_id":"2479ed6b-625f-4579-97f1-c20351f7fc6d","html_url":"https://github.com/nschloe/tikzplotlib","commit_stats":null,"previous_names":["nschloe/matplotlib2tikz","texworld/tikzplotlib"],"tags_count":82,"template":false,"template_full_name":null,"purl":"pkg:github/nschloe/tikzplotlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftikzplotlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftikzplotlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftikzplotlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftikzplotlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nschloe","download_url":"https://codeload.github.com/nschloe/tikzplotlib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftikzplotlib/sbom","scorecard":{"id":697068,"data":{"date":"2025-08-11","repo":{"name":"github.com/nschloe/tikzplotlib","commit":"450712b4014799ec5f151f234df84335c90f4b9d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4,"checks":[{"name":"Code-Review","score":2,"reason":"Found 1/4 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/nschloe/tikzplotlib/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/nschloe/tikzplotlib/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/nschloe/tikzplotlib/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/nschloe/tikzplotlib/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/nschloe/tikzplotlib/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/nschloe/tikzplotlib/ci.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:37","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T04:00:13.785Z","repository_id":780314,"created_at":"2025-08-22T04:00:13.785Z","updated_at":"2025-08-22T04:00:13.785Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["latex","matplotlib","pgfplots","python","tikz"],"created_at":"2024-08-02T12:01:07.955Z","updated_at":"2026-04-01T20:44:28.656Z","avatar_url":"https://github.com/nschloe.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/nschloe/tikzplotlib\"\u003e\u003cimg alt=\"tikzplotlib\" src=\"https://nschloe.github.io/tikzplotlib/logo-tikzplotlib.svg\" width=\"60%\"\u003e\u003c/a\u003e\n  \u003cp align=\"center\"\u003eThe artist formerly known as \u003cem\u003ematplotlib2tikz.\u003c/em\u003e\u003c/p\u003e\n\u003c/p\u003e\n\n[![PyPi Version](https://img.shields.io/pypi/v/tikzplotlib.svg?style=flat-square)](https://pypi.org/project/tikzplotlib)\n[![Packaging status](https://repology.org/badge/tiny-repos/python:tikzplotlib.svg)](https://repology.org/project/python:tikzplotlib/versions)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/tikzplotlib.svg?style=flat-square)](https://pypi.org/pypi/tikzplotlib/)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1173089.svg?style=flat-square)](https://doi.org/10.5281/zenodo.1173089)\n[![GitHub stars](https://img.shields.io/github/stars/nschloe/tikzplotlib.svg?style=flat-square\u0026logo=github\u0026label=Stars\u0026logoColor=white)](https://github.com/nschloe/tikzplotlib)\n[![Downloads](https://pepy.tech/badge/tikzplotlib/month?style=flat-square)](https://pepy.tech/project/tikzplotlib)\n\n\u003c!--[![PyPi downloads](https://img.shields.io/pypi/dm/tikzplotlib.svg?style=flat-square)](https://pypistats.org/packages/tikzplotlib)--\u003e\n\n[![Documentation Status](https://readthedocs.org/projects/tikzplotlib/badge/?version=latest\u0026style=flat-square)](https://readthedocs.org/projects/tikzplotlib/?badge=latest)\n[![awesome](https://img.shields.io/badge/awesome-yes-brightgreen.svg?style=flat-square)](https://github.com/nschloe/tikzplotlib)\n\n[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/tikzplotlib/ci?style=flat-square)](https://github.com/nschloe/tikzplotlib/actions?query=workflow%3Aci)\n[![codecov](https://img.shields.io/codecov/c/github/nschloe/tikzplotlib.svg?style=flat-square)](https://codecov.io/gh/nschloe/tikzplotlib)\n[![LGTM](https://img.shields.io/lgtm/grade/python/github/nschloe/tikzplotlib.svg?style=flat-square)](https://lgtm.com/projects/g/nschloe/tikzplotlib)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)\n\nThis is tikzplotlib, a Python tool for converting matplotlib figures into\n[PGFPlots](https://www.ctan.org/pkg/pgfplots) ([PGF/TikZ](https://www.ctan.org/pkg/pgf))\nfigures like\n\n![](https://nschloe.github.io/tikzplotlib/example.png)\n\nfor native inclusion into LaTeX or ConTeXt documents.\n\nThe output of tikzplotlib is in [PGFPlots](https://github.com/pgf-tikz/pgfplots/), a TeX\nlibrary that sits on top of [PGF/TikZ](https://en.wikipedia.org/wiki/PGF/TikZ) and\ndescribes graphs in terms of axes, data etc. Consequently, the output of tikzplotlib\n\n-   retains more information,\n-   can be more easily understood, and\n-   is more easily editable\n\nthan [raw TikZ output](https://matplotlib.org/users/whats_new.html#pgf-tikz-backend).\nFor example, the matplotlib figure\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nplt.style.use(\"ggplot\")\n\nt = np.arange(0.0, 2.0, 0.1)\ns = np.sin(2 * np.pi * t)\ns2 = np.cos(2 * np.pi * t)\nplt.plot(t, s, \"o-\", lw=4.1)\nplt.plot(t, s2, \"o-\", lw=4.1)\nplt.xlabel(\"time (s)\")\nplt.ylabel(\"Voltage (mV)\")\nplt.title(\"Simple plot $\\\\frac{\\\\alpha}{2}$\")\nplt.grid(True)\n\nimport tikzplotlib\n\ntikzplotlib.save(\"test.tex\")\n```\n\n\u003c!--close the figure and reset defaults\n\u003c!--pytest-codeblocks:cont--\u003e\n\n```python\nimport matplotlib as mpl\n\nplt.close()\nmpl.rcParams.update(mpl.rcParamsDefault)\n```\n\n--\u003e\n(see above) gives\n\n```latex\n\\begin{tikzpicture}\n\n\\definecolor{color0}{rgb}{0.886274509803922,0.290196078431373,0.2}\n\\definecolor{color1}{rgb}{0.203921568627451,0.541176470588235,0.741176470588235}\n\n\\begin{axis}[\naxis background/.style={fill=white!89.8039215686275!black},\naxis line style={white},\ntick align=outside,\ntick pos=left,\ntitle={Simple plot \\(\\displaystyle \\frac{\\alpha}{2}\\)},\nx grid style={white},\nxlabel={time (s)},\nxmajorgrids,\nxmin=-0.095, xmax=1.995,\nxtick style={color=white!33.3333333333333!black},\ny grid style={white},\nylabel={Voltage (mV)},\nymajorgrids,\nymin=-1.1, ymax=1.1,\nytick style={color=white!33.3333333333333!black}\n]\n\\addplot [line width=1.64pt, color0, mark=*, mark size=3, mark options={solid}]\ntable {%\n0 0\n0.1 0.587785252292473\n% [...]\n1.9 -0.587785252292473\n};\n\\addplot [line width=1.64pt, color1, mark=*, mark size=3, mark options={solid}]\ntable {%\n0 1\n0.1 0.809016994374947\n% [...]\n1.9 0.809016994374947\n};\n\\end{axis}\n\n\\end{tikzpicture}\n```\n\n(Use `get_tikz_code()` instead of `save()` if you want the code as a string.)\n\nTweaking the plot is straightforward and can be done as part of your TeX work flow.\n[The fantastic PGFPlots manual](http://pgfplots.sourceforge.net/pgfplots.pdf) contains\ngreat examples of how to make your plot look even better.\n\nOf course, not all figures produced by matplotlib can be converted without error.\nNotably, [3D plots don't work](https://github.com/matplotlib/matplotlib/issues/7243).\n\n### Installation\n\ntikzplotlib is [available from the Python Package\nIndex](https://pypi.org/project/tikzplotlib/), so simply do\n\n```\npip install tikzplotlib\n```\n\nto install.\n\n### Usage\n\n1. Generate your matplotlib plot as usual.\n\n2. Instead of `pyplot.show()`, invoke tikzplotlib by\n\n    ```python\n    import tikzplotlib\n\n    tikzplotlib.save(\"mytikz.tex\")\n    # or\n    tikzplotlib.save(\"mytikz.tex\", flavor=\"context\")\n    ```\n\n    to store the TikZ file as `mytikz.tex`.\n\n3. Add the contents of `mytikz.tex` into your TeX source code. A convenient way of doing\n   so is via\n\n    ```latex\n    \\input{/path/to/mytikz.tex}\n    ```\n\n    Also make sure that the packages for PGFPlots and proper Unicode support and are\n    included in the header of your document:\n\n    ```latex\n    \\usepackage[utf8]{inputenc}\n    \\usepackage{pgfplots}\n    \\DeclareUnicodeCharacter{2212}{−}\n    \\usepgfplotslibrary{groupplots,dateplot}\n    \\usetikzlibrary{patterns,shapes.arrows}\n    \\pgfplotsset{compat=newest}\n    ```\n\n    or:\n\n    ```latex\n    \\setupcolors[state=start]\n    \\usemodule[tikz]\n    \\usemodule[pgfplots]\n    \\usepgfplotslibrary[groupplots,dateplot]\n    \\usetikzlibrary[patterns,shapes.arrows]\n    \\pgfplotsset{compat=newest}\n    \\unexpanded\\def\\startgroupplot{\\groupplot}\n    \\unexpanded\\def\\stopgroupplot{\\endgroupplot}\n    ```\n\n    You can also get the code via:\n\n    ```python\n    import tikzplotlib\n\n    tikzplotlib.Flavors.latex.preamble()\n    # or\n    tikzplotlib.Flavors.context.preamble()\n    ```\n\n4. [Optional] Clean up the figure before exporting to tikz using the `clean_figure`\n   command.\n\n    ```python\n    import matplotlib.pyplot as plt\n    import numpy as np\n\n    # ... do your plotting\n\n    import tikzplotlib\n\n    tikzplotlib.clean_figure()\n    tikzplotlib.save(\"test.tex\")\n    ```\n\n    The command will remove points that are outside the axes limits, simplify curves and\n    reduce point density for the specified target resolution.\n\n    The feature originated from the\n    [matlab2tikz](https://github.com/matlab2tikz/matlab2tikz) project and is adapted to\n    matplotlib.\n\n### Contributing\n\nIf you experience bugs, would like to contribute, have nice examples of what tikzplotlib\ncan do, or if you are just looking for more information, then please visit\n[tikzplotlib's GitHub page](https://github.com/nschloe/tikzplotlib).\n\n### Testing\n\ntikzplotlib has automatic unit testing to make sure that the software doesn't\naccidentally get worse over time. In `test/`, a number of test cases are specified.\nThose run through tikzplotlib and compare the output with a previously stored reference\nTeX file.\n\nTo run the tests, just check out this repository and type\n\n```\npytest\n```\n\n### License\n\ntikzplotlib is published under the [MIT\nlicense](https://en.wikipedia.org/wiki/MIT_License).\n","funding_links":["https://github.com/sponsors/nschloe","nschloe"],"categories":["Tools","Python","Packages"],"sub_categories":["Graphics"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnschloe%2Ftikzplotlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnschloe%2Ftikzplotlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnschloe%2Ftikzplotlib/lists"}