matlab中jet的例⼦,Pythonmatplotlib.pyplot.jet()⽤法。。。Matplotlib是Python中的⼀个库,它是数字的-NumPy库的数学扩展。 Pyplot是Matplotlib模块的基于状态的接⼝,该模块提供了MATLAB-like接⼝。
matplotlib.pyplot.jet()功能:
matplotlib库的pyplot模块中的jet()函数⽤于将颜⾊映射设置为“jet”。
⽤法: matplotlib.pyplot.jet()
参数:此⽅法不接受任何参数。
返回:此⽅法不返回任何值。
以下⽰例说明了matplotlib.pyplot中的matplotlib.pyplot.jet()函数:
范例1:
# Implementation of matplotlib function
import matplotlib.pyplot as plt
i as tri
import numpy as np
ang = 40
rad = 10
radm = 0.35
radii = np.linspace(radm, 0.95, rad)
angles = np.linspace(0, 4 * np.pi, ang)
angles = np.repeat(angles[..., np.newaxis], rad, axis = 1)
angles[:, 1::2] += np.pi / ang
x = (radii * np.cos(angles)).flatten()
y = (radii * np.sin(angles)).flatten()
matplotlib中subplot
z = (np.sin(4 * radii) * np.cos(4 * angles)).flatten()
triang = tri.Triangulation(x, y)
triang.set_mask(np.hypot(iangles].mean(axis = 1),
iangles].mean(axis = 1))
< radm)
tpc = ipcolor(triang, z, shading ='flat')
plt.jet()
plt.title('matplotlib.pyplot.jet() function Example',
fontweight ="bold")
plt.show()
输出:
范例2:
# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
lors import LogNorm
dx, dy = 0.015, 0.05
x = np.arange(-3.0, 3.0, dx)
y = np.arange(-3.0, 3.0, dy)
X, Y = np.meshgrid(x, y)
extent = np.min(x), np.max(x), np.min(y), np.max(y)
Z1 = np.add.outer(range(6), range(6)) % 2
plt.imshow(Z1, cmap ="binary_r", interpolation ='nearest', extent = extent, alpha = 1)
def geeks(x, y):
return (1 - x / 2 + x**5 + y**6) * np.exp(-(x**2 + y**2))
Z2 = geeks(X, Y)
plt.imshow(Z2, alpha = 0.7, interpolation ='bilinear', extent = extent)
plt.jet()
plt.title('matplotlib.pyplot.jet() function Example', fontweight ="bold")
plt.show()
输出:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论