- 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`.
"""
importmatplotlib.pyplotasplt
importnumpyasnp
fromdata_prototype.artistimportCompatibilityAxes
fromdata_prototype.imageimportImage
fromdata_prototype.containersimportFuncContainer
frommatplotlib.colorsimportNormalize
fc=FuncContainer(
{},
xyfuncs={
"x": ((2,), lambdax, y: [x[0], x[-1]]),
"y": ((2,), lambdax, y: [y[0], y[-1]]),
"image": (
("N", "M"),
lambdax, 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()