Skip to main content

matplotlib-label-lines

Build Status codecov

Easily label line(s) using matplotlib.

The code is heavily based on http://stackoverflow.com/questions/16992038/inline-labels-in-matplotlib (original code from NauticalMile).

Install

Just do:

pip install matplotlib-label-lines

You can try it online on binder Binder or use the following script:

import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import loglaplace,chi2

from labellines import labelLine, labelLines

X = np.linspace(0,1,500)
A = [1,2,5,10,20]
funcs = [np.arctan,np.sin,loglaplace(4).pdf,chi2(5).pdf]

plt.subplot(321)
for a in A:
    plt.plot(X,np.arctan(a*X),label=str(a))

labelLines(plt.gca().get_lines(),zorder=2.5)

plt.subplot(322)
for a in A:
    plt.plot(X,np.sin(a*X),label=str(a))

labelLines(plt.gca().get_lines(),align=False,fontsize=14)

plt.subplot(323)
for a in A:
    plt.plot(X,loglaplace(4).pdf(a*X),label=str(a))

xvals = [0.8,0.55,0.22,0.104,0.045]
labelLines(plt.gca().get_lines(),align=False,xvals=xvals,color='k')

plt.subplot(324)
for a in A:
    plt.plot(X,chi2(5).pdf(a*X),label=str(a))

lines = plt.gca().get_lines()
l1=lines[-1]
labelLine(l1,0.6,label=r'$Re=${}'.format(l1.get_label()),ha='left',va='bottom',align = False)
labelLines(lines[:-1],align=False)

# labelLines also supports log-scaled x-axes
plt.subplot(325)
for a in A:
    plt.semilogx(X,np.arctan(5*a*X),label=str(a))

labelLines(plt.gca().get_lines(),zorder=2.5)

plt.subplot(326)
for a in A:
    plt.semilogx(X,chi2(5).pdf(a*X),label=str(a))

labelLines(plt.gca().get_lines(), xvals=(0.1, 1), zorder=2.5)

plt.show()

Example

Metadata

Release files for matplotlib-label-lines 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matplotlib-label-lines 0.3.7
File Size Uploaded Provenance Actions
matplotlib-label-lines-0.3.7.tar.gz 5.8 kB Without provenance Details for matplotlib-label-lines-0.3.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for matplotlib-label-lines 0.3.7
File Interpreter ABI Platform Actions
matplotlib_label_lines-0.3.7-py3-none-any.whl Python 3 none any Details for matplotlib_label_lines-0.3.7-py3-none-any.whl

Total release size: 12.0 kB

Release files / matplotlib-label-lines-0.3.7.tar.gz

Download URL matplotlib-label-lines-0.3.7.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7302102bd2b9f5171b0a69ae1d2ba5d02a0f55375c9d0bc86e8ba35ba4764e85
BLAKE2b-256 checksum
How to use checksums
56c1b0722dcc6fe77a8b6809e3f0583a1cc58772b25cae414817e5d0bd34e8bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release files / matplotlib_label_lines-0.3.7-py3-none-any.whl

Download URL matplotlib_label_lines-0.3.7-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d06b9c9c70e2a96af4ab0acd5c8d7c86b3f3cd808637f16b3c8c4fd7019fb30
BLAKE2b-256 checksum
How to use checksums
f5a233d84d9ca7f0b52be32077dd090535a304bc3e89d0fc6c6e56f4eb64c452
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Security for matplotlib-label-lines 0.3.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page