Phần 25: 3D Wireframe plot – Matplotib Basic

Phần 25: 3D Wireframe plot                        – Matplotib Basic

1. Khái niệm :

Biểu đồ Wireframe lấy 1 mạng lưới những giá trị và chiếu nó lên bề mặt ba chiều được chỉ định và có thể tạo nên các dạng ba chiều nhận được tương đối dễ hình dung. Hàm plot_wireframe () được dùng cho mục đích –
from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
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.determine()
ax = plt.axes(projection='3d')
ax.plot_wireframe(X, Y, Z, colour='black')
ax.set_title('wireframe')
plt.present()
Kết quả như dưới đây :

2. Ví dụ

'''
=================
3D wireframe plot
=================

A really fundamental demonstration of a wireframe plot.
'''

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt


fig = plt.determine()
ax = fig.add_subplot(111, projection='3d')

# Grab some check knowledge.
X, Y, Z = axes3d.get_test_data(0.05)

# Plot a fundamental wireframe.
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

plt.present()

admin

Leave a Reply

Your email address will not be published. Required fields are marked *