numpy.meshgrid
輸入坐標(biāo)向量返回對(duì)應(yīng)的矩陣氧腰。
Return coordinate matrices from coordinate vectors.
np.meshgrid(x1,x2,...,indexing,sparse=False,copy)
x = np.arange(-5, 5, 0.1)
y = np.arange(-5, 5, 0.1)
xx, yy = meshgrid(x, y, sparse=True)
z = np.sin(xx**2 + yy**2) / (xx**2 + yy**2)
h = plt.contourf(x,y,z)
plt.show()
matplotlib.pyplot.contour
contour()畫(huà)輪廓線(等高線)付材;
contourf()填充等高線樊零。
numpy.r_
默認(rèn)按照行合并
>>>a=np.array([[1,2,3],[4,5,6]])
>>>np.r_[a,a]
array([[1, 2, 3],
[4, 5, 6],
[1, 2, 3],
[4, 5, 6]])
給出了合并軸則按照指定軸合并
>>>np.r_['-1',a,a]
array([[1, 2, 3, 1, 2, 3],
[4, 5, 6, 4, 5, 6]])
使用‘r’或‘c’生成矩陣
>>>np.r_['r',[1,2,3], [4,5,6]]
matrix([[1, 2, 3, 4, 5, 6]])
numpy.ravel()
返回連續(xù)扁平的數(shù)組(Return a contiguous flattened array)
numpy.ravel(a,order='C')
a:輸入的數(shù)組;
order:包括‘C’我磁、‘F’、‘A’驻襟、‘K’夺艰;a中的元素將按照索引的順序讀取沉衣;
x = np.array([[1, 2, 3], [4, 5, 6]])
x.ravel()
[1 2 3 4 5 6]
在一個(gè)二位數(shù)組中郁副,
‘C’ :row-major, C-style order,在內(nèi)存中按行存儲(chǔ)豌习,按行計(jì)算比較快;
‘F’ :column-major, Fortran-style order存谎,在內(nèi)存中按列存儲(chǔ)拔疚,按列計(jì)算較快;
C contiguous既荚,F(xiàn)ortran contiguous 詳見(jiàn):
https://stackoverflow.com/questions/26998223/what-is-the-difference-between-contiguous-and-non-contiguous-arrays