numpy.meshgrid() usage

 Used to generate grid point coordinate matrix

Syntax: X, Y = numpy.meshgrid(x, y)
The input x , y is the horizontal and vertical coordinate column vector (non-matrix) of the grid point,
and the output X , Y is the coordinate matrix .

import numpy as np
import matplotlib.pyplot as plt

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

X, Y = np.meshgrid(x, y)
print(X)
print(Y)


plt.plot(X, Y,
         color='red',  # 全部点设置为红色
         marker='.',  # 点的形状为圆点
         linestyle='')  # 线型为空,也即点与点之间不用线连接
plt.grid(True)
plt.show()

Guess you like

Origin blog.csdn.net/qq_40107571/article/details/131492136