-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path2Dfunc.py
42 lines (34 loc) · 922 Bytes
/
2Dfunc.py
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
35
36
37
38
39
40
41
42
"""
=====================
A functional 2D image
=====================
A 2D image generated using :class:`.containers.FuncContainer` and
:class:`wrappers.ImageWrapper`.
"""
import matplotlib.pyplot as plt
import numpy as np
from data_prototype.artist import CompatibilityAxes
from data_prototype.image import Image
from data_prototype.containers import FuncContainer
from matplotlib.colors import Normalize
fc = FuncContainer(
{},
xyfuncs={
"x": ((2,), lambda x, y: [x[0], x[-1]]),
"y": ((2,), lambda x, y: [y[0], y[-1]]),
"image": (
("N", "M"),
lambda x, y: np.sin(x).reshape(1, -1) * np.cos(y).reshape(-1, 1),
),
},
)
norm = Normalize(vmin=-1, vmax=1)
im = Image(fc, norm=norm)
fig, nax = plt.subplots()
ax = CompatibilityAxes(nax)
nax.add_artist(ax)
ax.add_artist(im)
ax.set_xlim(-5, 5)
ax.set_ylim(-5, 5)
# fig.colorbar(im, ax=nax)
plt.show()