马上520,python的表白代码要来啦,看过了2D,今天给大家分享一款3D玫瑰花的绘制代码,快快动动你的小手打开py文件,快去表白吧!!
直接上代码
from mpl_toolkits.mplot3d import Axes3Dfrom matplotlib import cmfrom matplotlib.ticker import LinearLocatorimport matplotlib.pyplot as plt import numpy as npfig = plt.figure() ax = fig.gca(projection='3d') [x, t] = np.meshgrid(np.array(range(25))/24.0, np.arange(0, 575.5, 0.5)/575*17*np.pi-2*np.pi)p = (np.pi/2)*np.exp(-t/(8*np.pi))u = 1-(1-np.mod(3.6*t, 2*np.pi)/np.pi)**4/2y = 2*(x**2-x)**2*np.sin(p)r = u*(x*np.sin(p)+y*np.cos(p))surf = ax.plot_surface(r*np.cos(t), r*np.sin(t),u*(x*np.cos(p)-y*np.sin(p)), rstride=1, cstride=1, cmap=cm.Reds_r,linewidth=0, antialiased=True)#更改代码:#直接写你想说的话,但是要英文哟!plt.xlabel('❤')plt.ylabel('❤')plt.title('love you❤')plt.show()
来看看效果吧
最近看了房琪的书,分享一句话。站在高处望深渊,坠入深渊识攀爬。人不活一个点,人活起伏。
来源地址:https://blog.csdn.net/m0_61497715/article/details/129997991