mpl-gradients
A lightweight, zero-dependency library to add linear gradient fills to Matplotlib charts. Solves matplotlib/matplotlib#30958.
Features
- Vertical Gradients: Fade from Top to Bottom.
- Horizontal Gradients: Fade from Left to Right.
- Diagonal Gradients: Fade from Corner to Corner.
- Alpha Blending: Correctly handles transparency.
Installation
You can install directly from GitHub:
pip install mpl-gradients
Quick start
import matplotlib.pyplot as plt
from mpl_gradients import LinearGradient
fig, ax = plt.subplots()
ax.bar([0, 1, 2], [10, 20, 15])
# Create a gradient (Top-Left Navy -> Bottom-Right Lime)
gradient = LinearGradient("navy", "lime", direction="diagonal")
# Apply to bars
for bar in ax.containers[0]:
bar.set_agg_filter(gradient)
plt.show()
Requirements
Python 3.9+
Matplotlib
Numpy
New in v0.2.0: Transparency Support
You can now create gradients that fade to transparent!
By default, gradients preserve the original alpha of the plot (preserve_alpha=True).
To create transparent gradients (e.g., Red -> Transparent), set preserve_alpha=False.
from mpl_gradients import LinearGradient
# Create a gradient that fades from Red to Transparent to Green
gradient = LinearGradient.from_colors(
["red", "#ffffff00", "green"],
preserve_alpha=False
)
# Apply it
ax.fill_between(x, y, color="blue").set_agg_filter(gradient)
Metadata
Release files for mpl-gradients 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mpl_gradients-0.2.1.tar.gz | 5.4 kB | Without provenance | Details for mpl_gradients-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mpl_gradients-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for mpl_gradients-0.2.1-py3-none-any.whl |
Total release size: 11.1 kB
Release files / mpl_gradients-0.2.1.tar.gz
| Download URL | mpl_gradients-0.2.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07701085e338f1bd85777917c5519b24195951ce55b77430035c6997a13dc0a8
|
|
BLAKE2b-256 checksum How to use checksums |
aa9cebbd1e05c0f1f642bd744d6bf81283b72f81e2b0e0638ecbc4d86110377d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / mpl_gradients-0.2.1-py3-none-any.whl
| Download URL | mpl_gradients-0.2.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0af64c3c87d4e8c26b3281572be667a5076389c09ecf2f0cfd45919021de59ba
|
|
BLAKE2b-256 checksum How to use checksums |
3fe3cd695b814ce6dddf66d097d62d28bab8c1c998ec520c8af8f944a94171a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for mpl-gradients 0.2.1
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.