File size: 1,382 Bytes
d323f57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
import matplotlib.pyplot as plt

# ── Parameters ─────────────────────────────────────────────────────────────
seed      = 1408
size      = 27
colormap  = "viridis"
n_blobs   = 2

# ── Data ────────────────────────────────────────────────────────────────────
x = np.linspace(-3.0, 3.0, size)
y = np.linspace(-2.0, 4.0, size)
X, Y = np.meshgrid(x, y)
Z = np.zeros((size, size))

Z += 1.100471 * np.exp(
    -((X - 1.465182)**2 / (2 * 0.511779**2)
      + (Y - 0.593035)**2 / (2 * 0.580871**2))
)
Z += 1.249910 * np.exp(
    -((X - -1.338179)**2 / (2 * 0.673453**2)
      + (Y - 0.007833)**2 / (2 * 0.805244**2))
)

# ── Plot ────────────────────────────────────────────────────────────────────
fig, ax = plt.subplots(figsize=(6, 5))
im = ax.pcolormesh(X, Y, Z, cmap=colormap, shading="auto")
fig.colorbar(im, ax=ax, label="Intensity")
ax.set_title(f"Gaussian Heatmap  ({n_blobs} blob(s))")
ax.set_xlabel("X")
ax.set_ylabel("Y")
fig.tight_layout()
plt.show()