Python 3D爱心(Maptlotlib)

import numpy as np

import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D

 

fig = plt.figure()

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

 

x = np.linspace(-2, 2, 100)

y = np.linspace(-2, 2, 100)

x, y = np.meshgrid(x, y)

z = x**2 + (5*y/4 - np.sqrt(np.abs(x)))**2

 

ax.plot_surface(x, y, z, color='red')

ax.set_title("3D Love Heart")

plt.show()

你可能感兴趣的:(3d,python)