CDA会员俱乐部 加入小组

388个成员 140个话题 创建时间:2017-12-01

情人节——用Python画一朵美丽的玫瑰花

发表于2020-02-14 1728次查看
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator
import matplotlib.pyplot as plt
import numpy as np

fig=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/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.inferno,linewidth=0,antialiased=True)
plt.show()

1回复
  • 2楼 山有木兮水有鱼 2020-02-14

    颜色参数可在cmap调整

    cmap=cm.inferno
    #('viridis',' inferno', 'plasma',' magma','Blues','BuGn',' BuPu','GnBu',' Greens','Greys', ‘Oranges','OrRd','PuBu',' PuBuGn', 'PuRd', . Purples' RdPu  'Reds  'YlGn','YlGnBu', 'YlorBr', 'YlorRd',afmhot', 'autumn','bone','cool','copper', 'gist_ heat', gray', 'hot','pink', 'spring', 'summer','winter','BrBG',' bwr',' coolwarm','PiYG','PRGn','Puor' ,'RdBu','RdGy', 'RdY1Bu',' RdY1Gn','Spectral',' seismic','Accent','Dark2', 'Paired', 'Pastel1', . Pastel2', 'Set1','Set2','Set3','gist_ earth','terrain','ocean','gist_ stern','brg','CMRmap', 'cubehelix', ' gnuplot','gnuplot2' ,'gist_ ncar', 'nipy_ spectral', 'jet' ,'rainbow',' gist_ rainbow') 

     

发表回复
你还没有登录,请先 登录或 注册!