Python 官方文档:入门教程 => 点击学习
本篇内容主要讲解“python怎么绘制3D立体花朵”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Python怎么绘制3D立体花朵”吧!动态展示这是一个动态图哦导读兄弟们可以收藏一下哦!情人节可以
本篇内容主要讲解“python怎么绘制3D立体花朵”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Python怎么绘制3D立体花朵”吧!
这是一个动态图哦
兄弟们可以收藏一下哦!情人节可以送出去,肥学找了几朵python写的花给封装好送给大家。不是多炫酷但是有足够的用心哦。别忘了点赞呀我也就不细说了,来吧展示!
def lotus(): fig = plt.figure(figsize=(10,7),facecolor='black',clear=True) 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/2 y = 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.GISt_rainbow_r, linewidth=0, antialiased=True)
效果图
def rose_flower(): fig = plt.figure(figsize=(10,7),facecolor='black',clear=True) ax = fig.gca(projection='3d') # 将相位向后移动了6*pi [x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 20 * np.pi + 4*np.pi) p = (np.pi / 2) * np.exp(-t / (8 * np.pi)) # 添加边缘扰动 change = np.sin(15*t)/150 # 将t的参数减少,使花瓣的角度变大 u = 1 - (1 - np.mod(3.3 * t, 2 * np.pi) / np.pi) ** 4 / 2 + change y = 2 * (x ** 2 - x) ** 2 * np.sin(p) r = u * (x * np.sin(p) + y * np.cos(p)) h = u * (x * np.cos(p) - y * np.sin(p)) c= cm.get_cmap('Reds') surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap= c, linewidth=0, antialiased=True)
效果图
def peach_blossom(): fig = plt.figure(figsize=(10,7),facecolor='black',clear=True) ax = fig.gca(projection='3d') [x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 6 * np.pi - 4*np.pi) p = (np.pi / 2) * np.exp(-t / (8 * np.pi)) change = np.sin(10*t)/20 u = 1 - (1 - np.mod(5.2 * t, 2 * np.pi) / np.pi) ** 4 / 2 + change y = 2 * (x ** 2 - x) ** 2 * np.sin(p) r = u * (x * np.sin(p) + y * np.cos(p)) * 1.5 h = u * (x * np.cos(p) - y * np.sin(p)) c= cm.get_cmap('spring_r') surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap= c, linewidth=0, antialiased=True)
效果图
def monthly_rose(): fig = plt.figure(figsize=(10,7),facecolor='black',clear=True) ax = fig.gca(projection='3d') [x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 30 * np.pi - 4 * np.pi) p = (np.pi / 2) * np.exp(-t / (8 * np.pi)) change = np.sin(20 * t) / 50 u = 1 - (1 - np.mod(3.3 * t, 2 * np.pi) / np.pi) ** 4 / 2 + change y = 2 * (x ** 2 - x) ** 2 * np.sin(p) r = u * (x * np.sin(p) + y * np.cos(p)) * 1.5 h = u * (x * np.cos(p) - y * np.sin(p)) c = cm.get_cmap('magma') surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap=c, linewidth=0, antialiased=True)
效果图
到此,相信大家对“Python怎么绘制3D立体花朵”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
--结束END--
本文标题: Python怎么绘制3D立体花朵
本文链接: https://lsjlt.com/news/301010.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0