Skip to content

maroba/mplshared

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mplshared

Some tools for matplotlib.

PyPI version fury.io PyPI license

Usage

pip install --upgrade mplshared

Slope Lines

In plots with linearly scaling axes:

import matplotlib.pyplot as plt
from mplshared import SlopeLine

# Get some random data:
x = np.linspace(0, 10, 100)
y = noisify(2 * x + 3)

# Plot it:
plt.plot(x, y)

# Add a slope line:

slope_line = SlopeLine(slope=2, through=(x[5], y[5]), domain=(0, 10))
plt.gca().add_line(slope_line)
plt.show()

docs/pyplots/slopeline_linear.png

If you have a loglog plot, just change the scale argument:

slope_line = SlopeLine(slope=2,
                   through=(x[40], y[40]),
                   domain=(1, 100),
                   scale='loglog',
                   style={'color': 'red'}
                   )

docs/pyplots/slopeline_loglog.png

StepFunctionLine

import numpy as np
import matplotlib.pyplot as plt

from mplshared import StepFunctionLine

x = np.linspace(-3, 3, 20)
y = np.sin(x)

sf1 = StepFunctionLine(x, y, linewidth=3, color='red')
plt.gca().add_line(sf1)
sf1.autolims(plt)
plt.show()

docs/pyplots/stepfunction_1.png

About

Some tools for matplotlib

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages