"""
使用Numpy数组可以利用简单的数组表达式完成多种数据操作任务,无需写大量循环,这种利用数组表达式来替代显示循环的方法称为向量化
"""
import numpy as np
import matplotlib.pyplot as plt
points = np.arange(-5, 5, 0.01)
xs, ys = np.meshgrid(points, points)
z = np.sqrt(xs ** 2, ys ** 2)
plt.imshow(z, cmap=plt.cm.gray)
plt.colorbar()
plt.title("Image plot of $\sqrt{x^2 + y^2}$ for a grid of values")
一、Numpy-9.使用数组进行面向数组编程
最新推荐文章于 2024-07-23 11:46:27 发布