20 · envelope¶
series.envelope shades the band between a lower and upper series (cleopatra LineGlyph.fill_between).
Setup — inline plots and the path to the bundled Lisbon DEM.
In [1]:
Copied!
%matplotlib inline
from pathlib import Path
# Locate the bundled Lisbon DEM from the repo root (works from docs/ or the repo root).
ROOT = Path.cwd()
while not (ROOT / "examples" / "data" / "LisbonElevation.tif").exists() and ROOT != ROOT.parent:
ROOT = ROOT.parent
DEM = str(ROOT / "examples" / "data" / "LisbonElevation.tif")
import numpy as np
import matplotlib.pyplot as plt
from digitalearth.static.charts import series
rng = np.random.default_rng(0)
%matplotlib inline
from pathlib import Path
# Locate the bundled Lisbon DEM from the repo root (works from docs/ or the repo root).
ROOT = Path.cwd()
while not (ROOT / "examples" / "data" / "LisbonElevation.tif").exists() and ROOT != ROOT.parent:
ROOT = ROOT.parent
DEM = str(ROOT / "examples" / "data" / "LisbonElevation.tif")
import numpy as np
import matplotlib.pyplot as plt
from digitalearth.static.charts import series
rng = np.random.default_rng(0)
Shade a ±spread envelope around a mean curve.
In [2]:
Copied!
x = np.arange(40)
mean = np.sin(x / 6)
lo, hi = mean - 0.4, mean + 0.4
fig, ax = plt.subplots(figsize=(8, 3))
series.envelope(x, lo, hi, ax=ax, alpha=0.3)
ax.plot(x, mean)
ax.set_title('envelope')
fig;
x = np.arange(40)
mean = np.sin(x / 6)
lo, hi = mean - 0.4, mean + 0.4
fig, ax = plt.subplots(figsize=(8, 3))
series.envelope(x, lo, hi, ax=ax, alpha=0.3)
ax.plot(x, mean)
ax.set_title('envelope')
fig;