one stop shop for matplotlib plots
Project description
Matplotlib is great library which offers huge flexibility due to its object oriented
programming style. However, most of the times, we the users don't need that
much flexibiliy and just want to get things done as quickly as possible. For example
why should I write at least three lines to plot a simple array with legend when same
can be done in one line and my purpose is just to view the array. Why I can't simply
do plot(data)
or imshow(img)
. This motivation gave birth to this library.
easy_mpl
stands for easy maplotlib. The purpose of this is to ease the use of
matplotlib while keeping the flexibility of object oriented programming paradigm
of matplotlib intact. Using these one liners will save the time and will not hurt.
Moreover, you can swap every function of this library with that of matplotlib and
vice versa.
Installation
This package can be installed using pip from pypi using following command
pip install easy_mpl
Usage
plot
from easy_mpl import plot
import numpy as np
plot(np.random.random(100))
# use x and y
plot(np.arange(100), np.random.random(100))
# use x and y with marker style
plot(np.arange(100), np.random.random(100), '.')
plot(np.random.random(100), '.')
# use cutom marker
plot(np.random.random(100), '--*')
plot(np.random.random(100), '--*', label='label')
# log transform y-axis
plot(np.random.random(100), '--*', logy=True, label='label')
bar_chart
from easy_mpl import bar_chart
bar_chart([1,2,3,4,4,5,3,2,5])
# specifying labels
bar_chart([3,4,2,5,10], ['a', 'b', 'c', 'd', 'e'])
# sorting the data
bar_chart([1,2,3,4,4,5,3,2,5], sort=True)
regplot
import numpy as np
from easy_mpl import regplot
x_, y_ = np.random.random(100), np.random.random(100)
regplot(x_, y_)
imshow
import numpy as np
from easy_mpl import imshow
x = np.random.random((10, 5))
imshow(x, annotate=True)
# show colorbar
imshow(x, colorbar=True)
hist
from easy_mpl import hist
import numpy as np
hist(np.random.random((10, 1)))
pie
from easy_mpl import pie
import numpy as np
pie(np.random.randint(0, 3, 100))
# or by directly providing fractions
pie([0.2, 0.3, 0.1, 0.4])
scatter
import numpy as np
from easy_mpl import scatter
import matplotlib.pyplot as plt
x = np.random.random(100)
y = np.random.random(100)
scatter(x, y, show=False)
# show colorbar
scatter(x, y, colorbar=True, show=False)
# retrieve axes for further processing
ax, _ = scatter(x, y, show=False)
assert isinstance(ax, plt.Axes)
contour
from easy_mpl import contour
import numpy as np
x = np.random.uniform(-2, 2, 200)
y = np.random.uniform(-2, 2, 200)
z = x * np.exp(-x**2 - y**2)
contour(x, y, z, fill_between=True, show_points=True)
# show contour labels
contour(x, y, z, label_contours=True, show_points=True)
dumbbell_plot
import numpy as np
from easy_mpl import dumbbell_plot
st = np.random.randint(1, 5, 10)
en = np.random.randint(11, 20, 10)
dumbbell_plot(st, en)
# modify line color
dumbbell_plot(st, en, line_kws={'color':"black"})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file easy_mpl-0.1.0.tar.gz
.
File metadata
- Download URL: easy_mpl-0.1.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d41da3b1dd9ad1a0e4ebf271b8afd4a1275ebfbcddd903fbbcfee80bcf4722fc |
|
MD5 | 8c99dafa42b4aecfc4a2b9fb5ae998e4 |
|
BLAKE2b-256 | 1d32e276dc2768c3792ff08baddcfbbf0266a906dbfe799b2eee67f624f26106 |