Skip to main content

Create fillbetween plots filled with any colormap

Project description

mpl_fill_cmap_between

Create fill_between-like plots filled with any matplotlib's colormap.

Install

pip install mpl_fill_cmap_between

Examples

The function fill_cmap_between (and also the function fill_cmap_between_x) can be used in the following manner:

import numpy as np
import matplotlib.pyplot as plt
from mpl_fill_cmap_between import fill_cmap_between, fill_cmap_between_x

x = np.linspace(-10, 10, 50)
y = x**2 - 40

fig = plt.figure(figsize=(4.8, 2.0))
ax = fig.add_subplot(111)

fill_cmap_between(x, y * 0.1, 0, ax=ax, cmap="viridis", kw_line_1=dict(color="k"),
                  kw_line_2=dict(color="k", lw=0.5))
ax.set_aspect("equal")

fig.tight_layout()
fig.savefig("example.pdf", dpi=300)

Example

The plot can also be rotated by an angle from a given origin:

import numpy as np
import matplotlib.pyplot as plt
from mpl_fill_cmap_between import fill_cmap_between, fill_cmap_between_x

x = np.linspace(0, 10, 50)
y = (x - 5)**2 - 10

fig = plt.figure(figsize=(4.8, 2.0))
ax = fig.add_subplot(111)

fill_cmap_between(x, y * 0.1, 0, ax=ax, cmap="viridis", kw_line_1=dict(color="k"),
                  kw_line_2=dict(color="k", lw=0.5), angle=40, origin=(10, 0))
ax.set_aspect("equal")
ax.grid(True, ls=":")

fig.tight_layout()
fig.savefig("example_02.png", dpi=300)

Example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpl_fill_cmap_between-0.3.1.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

mpl_fill_cmap_between-0.3.1-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page