English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Matplotlib 3D wireframe plot

The wireframe plot uses a value grid and projects it onto the specified three-dimensional surface, making it very easy to visualize the three-dimensional form. The plot_wireframe() function is used for this purpose -

# Filename : example.py
# Copyright : 2020 By w3codebox
# Author by : www.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], commercial redistribution requires authorization from the author, non-commercial redistribution requires retention of the original link:
 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('Wireframe Plot')
 plt.show()

Running the above example code, the following results are obtained -