Skip to content
svgvariogram

Semivariogram

How far does resemblance reach before sites are no more alike than any two sites?

Demo data · seed 20261101 · 15 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read x as the distance between two sites and y as how much they differ on average.
  2. Follow the rise: near sites are more alike than far ones until the curve levels off at the sill.
  3. Read the distance where it levels off as the range, and the height at distance zero as the nugget.
  1. Callout 1: The nugget: difference between sites at almost no distance.
  2. Callout 2: The sill: pairs this far apart are no more alike than any two sites.
  3. Callout 3: Band from shuffled values: points inside it show no spatial structure.
  4. Callout 4: Larger points are classes with more pairs.

Watch out

  • A curve that keeps rising usually means a trend across the map, not a long range. Remove the trend and look at the residuals.
  • Classes with few pairs are noisy. Don't read much into small points.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Semivariance rises with distance when near sites are more alike than far ones. It levels off at the sill, near the variance, at about the practical range.
  • The jump at distance 0 is the nugget: measurement error or variation at scales below the closest sites.
  • Points inside the shuffled band are no more alike than random pairs. Classes with few pairs are noisy, so point area shows the pairs.

Use with care

A semivariance that keeps rising usually means a trend across the map, not a long range: remove the trend and look at its residuals.

# Semivariogram — Codesplash Chart Lab (recipe "variogram")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("variogram-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
H = "distance"
GAMMA = "semivariance"
PAIRS = "pairs"
LO = "shuffled low"
HI = "shuffled high"
FITTED = "fitted"
VARIANCE = None  # the data's variance, when the analysis reports it
d = df.dropna(subset=[H, GAMMA]).sort_values(H)
h = d[H].to_numpy(dtype=float)
area = d[PAIRS].to_numpy(dtype=float) / d[PAIRS].max() if PAIRS else np.full(len(d), 0.5)
fig, ax = plt.subplots(figsize=(8, 4.5))
if LO and HI:
    ax.fill_between(h, d[LO], d[HI], color=PALETTE[0], alpha=0.14, linewidth=0, label="shuffled values")
if VARIANCE is not None:
    ax.axhline(VARIANCE, color=REF, linestyle="--", linewidth=1, label="variance")
if FITTED:
    ax.plot(h, d[FITTED], color=PALETTE[1], linewidth=1.8, label="fitted model")
ax.scatter(h, d[GAMMA], s=20 + 120 * area, color=PALETTE[0], alpha=0.75, linewidths=0.7, edgecolors="white", label="semivariance (area = pairs)")
ax.set(xlim=(0, h.max() * 1.05), ylim=(0, None), xlabel=H, ylabel=GAMMA)
ax.legend(frameon=False, fontsize=8)
plt.show()

Needs pandas, numpy, matplotlib · reads variogram-demo.csv · app theme from the optional codesplash helper