线框图采用值网格并将其投影到指定的三维表面上,并且可以使得到的三维形式非常容易可视化。plot_wireframe()函数用于此目的 -
# Filename : example.py # Copyright : 2020 By Nhooo # Author by : www.528045.com # Date : 2020-08-08 #! /usr/bin/env python #coding=utf-8 import matplotlib.pyplot as plt import numpy as np import math import seaborn as sns plt.rcParams['font.sans-serif'] = ['SimHei'] # 步骤一(替换sans-serif字体) plt.rcParams['axes.unicode_minus'] = False # 原文出自【立地货】,商业转载请联系作者获得授权,非商业请保留原文链接: from mpl_toolkits import mplot3d def f(x, y): return np.sin(np.sqrt(x ** 2 + y ** 2)) x = np.linspace(-6, 6, 30) y = np.linspace(-6, 6, 30) def f(x, y): return np.sin(np.sqrt(x ** 2 + y ** 2)) x = np.linspace(-6, 6, 30) y = np.linspace(-6, 6, 30) X, Y = np.meshgrid(x, y) Z = f(X, Y) fig = plt.figure() ax = plt.axes(projection='3d') ax.plot_wireframe(X, Y, Z, color='black') ax.set_title('线框图') plt.show()
执行上面示例代码,得到以下结果 -