当前位置:   article > 正文

python绘制立体玫瑰花

python绘制立体玫瑰花

1.需要的程序包

matplotlib 
numpy

2.代码

  1. from matplotlib import cm
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. fig = plt.figure()#显示绘图窗口
  5. ax = fig.add_subplot(projection = '3d')#绘图窗口设置
  6. [x, t] = np.meshgrid(np.array(range(25))/24.0, np.arange(0, 575.5, 0.5)/575*17*np.pi-2*np.pi)
  7. p = (np.pi/2)*np.exp(-t/(8*np.pi))
  8. u = 1-(1-np.mod(3.6*t, 2*np.pi)/np.pi)**4/2
  9. y = 2*(x**2-x)**2*np.sin(p)
  10. r = u*(x*np.sin(p)+y*np.cos(p))
  11. surf = ax.plot_surface(r*np.cos(t), r*np.sin(t), u*(x*np.cos(p)-y*np.sin(p)), rstride=1,
  12. cstride=1,cmap=cm.Reds_r,linewidth = 0, antialiased = True)#根据参数绘图
  13. #自己设置文字内夸和显示设置
  14. ax.text(-0.3,0,1.2,'LOVE', color='red')
  15. plt.axis('off')
  16. plt.show()

3.运行结果


 

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号