{"id":19264162,"url":"https://github.com/cphyc/matplotlib-label-lines","last_synced_at":"2025-05-15T02:06:50.609Z","repository":{"id":18637852,"uuid":"84806363","full_name":"cphyc/matplotlib-label-lines","owner":"cphyc","description":"Label line using matplotlib.","archived":false,"fork":false,"pushed_at":"2025-05-05T19:28:42.000Z","size":7664,"stargazers_count":315,"open_issues_count":6,"forks_count":28,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-05T20:40:26.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/cphyc.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,"zenodo":null}},"created_at":"2017-03-13T09:13:08.000Z","updated_at":"2025-05-05T19:28:42.000Z","dependencies_parsed_at":"2023-02-16T13:30:34.213Z","dependency_job_id":"454a1bb4-9928-42c8-b66f-b609008812da","html_url":"https://github.com/cphyc/matplotlib-label-lines","commit_stats":{"total_commits":251,"total_committers":12,"mean_commits":"20.916666666666668","dds":0.6533864541832669,"last_synced_commit":"1f1ffd2817105aa9ce48ab5d33b6301d11ef9784"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fmatplotlib-label-lines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fmatplotlib-label-lines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fmatplotlib-label-lines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fmatplotlib-label-lines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cphyc","download_url":"https://codeload.github.com/cphyc/matplotlib-label-lines/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259370,"owners_count":22040819,"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":[],"created_at":"2024-11-09T19:40:03.947Z","updated_at":"2025-05-15T02:06:50.594Z","avatar_url":"https://github.com/cphyc.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# matplotlib-label-lines\n[![Build status](https://github.com/cphyc/matplotlib-label-lines/actions/workflows/pytest.yml/badge.svg)](https://github.com/cphyc/matplotlib-label-lines/actions/workflows/pytest.yml)\n[![Supported Python Versions](https://img.shields.io/pypi/pyversions/matplotlib-label-lines/0.7.0)](https://pypi.org/project/matplotlib-label-lines/)\n[![PyPI](https://img.shields.io/pypi/v/matplotlib-label-lines)](https://pypi.org/project/matplotlib-label-lines)\n[![codecov](https://codecov.io/gh/cphyc/matplotlib-label-lines/branch/master/graph/badge.svg)](https://codecov.io/gh/cphyc/matplotlib-label-lines)\n\nEasily label line(s) using matplotlib.\n\nThe code is heavily based on http://stackoverflow.com/questions/16992038/inline-labels-in-matplotlib (original code from NauticalMile).\n\n## Install\n\nJust do:\n```bash\npip install matplotlib-label-lines\n```\nYou can try it online on binder [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/cphyc/matplotlib-label-lines/master), get some inspiration from [the example](https://github.com/cphyc/matplotlib-label-lines/blob/master/example/matplotlib_label_lines.ipynb) or from the following script:\n```python\nimport numpy as np\nfrom matplotlib import pyplot as plt\nfrom scipy.stats import chi2, loglaplace\n\nfrom labellines import labelLine, labelLines\n\nX = np.linspace(0, 1, 500)\nA = [1, 2, 5, 10, 20]\nfuncs = [np.arctan, np.sin, loglaplace(4).pdf, chi2(5).pdf]\n\nfig, axes = plt.subplots(ncols=2, nrows=3, constrained_layout=True, figsize=(8, 8))\n\naxes = axes.flatten()\n\nax = axes[0]\nfor a in A:\n    ax.plot(X, np.arctan(a * X), label=str(a))\n\nlabelLines(ax.get_lines(), zorder=2.5)\n\nax = axes[1]\nfor a in A:\n    ax.plot(X, np.sin(a * X), label=str(a))\n\nlabelLines(ax.get_lines(), align=False, fontsize=14)\n\nax = axes[2]\nfor a in A:\n    ax.plot(X, loglaplace(4).pdf(a * X), label=str(a))\n\nxvals = [0.8, 0.55, 0.22, 0.104, 0.045]\nlabelLines(ax.get_lines(), align=False, xvals=xvals, color=\"k\")\n\nax = axes[3]\nfor a in A:\n    ax.plot(X, chi2(5).pdf(a * X), label=str(a))\n\nlines = ax.get_lines()\nl1 = lines[-1]\nlabelLine(\n    l1,\n    0.85,\n    label=r\"$Re=${}\".format(l1.get_label()),\n    align=False,\n    yoffset=0.01,\n    ha=\"right\",\n    backgroundcolor=\"none\",\n)\nlabelLines(lines[:-1], xvals=0.85, yoffsets=0.01, align=False,\n           ha=\"right\", backgroundcolor=\"none\")\n\n# labelLines also supports log-scaled x-axes\nax = axes[4]\nfor a in A:\n    ax.semilogx(X, np.arctan(5 * a * X), label=str(a))\n\nlabelLines(ax.get_lines(), zorder=2.5)\n\nax = axes[5]\nfor a in A:\n    ax.semilogx(X, chi2(5).pdf(a * X), label=str(a))\n\nlabelLines(ax.get_lines(), xvals=(0.1, 1), zorder=2.5)\n\nfig.show()\n```\n![Example](https://raw.githubusercontent.com/cphyc/matplotlib-label-lines/master/example.png)\n\n# Citing\nIf you're using this package for research purposes, consider citing the [Zenodo entry (https://zenodo.org/record/7428071)](https://zenodo.org/record/7428071).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcphyc%2Fmatplotlib-label-lines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcphyc%2Fmatplotlib-label-lines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcphyc%2Fmatplotlib-label-lines/lists"}