numpy meshgrid

numpy.meshgrid()

X,Y = numpy.meshgrid(x, y)
輸入: x,網格點的橫座標點組成的向量;y,網格點的縱座標點組成的向量。
輸出: X,Y爲橫縱座標矩陣。

import numpy as np
import matplotlib.pyplot as plt

x = np.array([1, 2, 3])
y = np.array([0, 1])

X, Y = np.meshgrid(x, y)
print("X coodinate:", X)
print("Y coodinate:", Y)
[[1 2 3]
 [1 2 3]]
[[0 0 0]
 [1 1 1]]


(1,0),(2,0),(3,0)
(1,1),(2,1),(3,1)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章