English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This surface plot shows the functional relationship between the specified dependent variable (Y) and two independent variables (X and Z). This graph is an accompanying graph of the contour plot. The surface plot is similar to the wireframe plot, but each face of the wireframe is a filled polygon. This can help perceive the topology of the visualized surface. The plot_surface() function takes x, y, and z as parameters.
# Filename : example.py # Copyright : 2020 By w3codebox # Author by : es.oldtoolbag.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'] # Step one (replace sans-serif font) plt.rcParams['axes.unicode_minus'] = False # Original text from [Lidi Huo], please contact the author for commercial use, and retain the original link for non-commercial use: from mpl_toolkits import mplot3d x = np.outer(np.linspace(-2, 2, 30), np.ones(30)) y = x.copy().T # transponer z = np.cos(x ** 2 + y ** 2) fig = plt.figure() ax = plt.axes(projection='3d') ax.plot_surface(x, y, z, cmap='viridis', edgecolor='none') ax.set_title('Gráfico de superficie') plt.show()
Ejecutar el código de ejemplo superior y obtener los siguientes resultados -