效果
快过年了,给你的电子女友送上一朵赛博玫瑰花吧!文章来源:https://www.toymoban.com/news/detail-826589.html
文章来源地址https://www.toymoban.com/news/detail-826589.html
代码与颜色参数
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_axes(Axes3D(fig))
[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 = plt.get_cmap('Accent') # 修改颜色
surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1,
cmap=c, linewidth=0, antialiased=True)
plt.show()
修改颜色语句 c = plt.get_cmap('Accent')
修改参数即可修改颜色,可选颜色参数如下:
Accent | Accent_r | Blues | Blues_r | BrBG | BrBG_r |
---|---|---|---|---|---|
BuGn | BuGn_r | BuPu | BuPu_r | CMRmap | CMRmap_r |
Dark2 | Dark2_r | GnBu | GnBu_r | Greens | Greens_r |
Greys | Greys_r | OrRd | OrRd_r | Oranges | Oranges_r |
PRGn | PRGn_r | Paired | Paired_r | Pastel1 | Pastel1_r |
Pastel2 | Pastel2_r | PiYG | PiYG_r | PuBu | PuBuGn |
PuBuGn_r | PuBu_r | PuOr | PuOr_r | PuRd | PuRd_r |
Purples | Purples_r | RdBu | RdBu_r | RdGy | RdGy_r |
RdPu | RdPu_r | RdYlBu | RdYlBu_r | RdYlGn | RdYlGn_r |
Reds | Reds_r | Set1 | Set1_r | Set2 | Set2_r |
Set3 | Set3_r | Spectral | Spectral_r | Wistia | Wistia_r |
YlGn | YlGnBu | YlGnBu_r | YlGn_r | YlOrBr | YlOrBr_r |
YlOrRd | YlOrRd_r | afmhot | afmhot_r | autumn | autumn_r |
binary | binary_r | bone | bone_r | brg | brg_r |
bwr | bwr_r | cividis | cividis_r | cool | cool_r |
coolwarm | coolwarm_r | copper | copper_r | cubehelix | cubehelix_r |
flag | flag_r | gist_earth | gist_earth_r | gist_gray | gist_gray_r |
gist_heat | gist_heat_r | gist_ncar | gist_ncar_r | gist_rainbow | gist_rainbow_r |
gist_stern | gist_stern_r | gist_yarg | gist_yarg_r | gnuplot | gnuplot2 |
gnuplot2_r | gnuplot_r | gray | gray_r | hot | hot_r |
hsv | hsv_r | inferno | inferno_r | jet | jet_r |
magma | magma_r | nipy_spectral | nipy_spectral_r | ocean | ocean_r |
pink | pink_r | plasma | plasma_r | prism | prism_r |
rainbow | rainbow_r | seismic | seismic_r | spring | spring_r |
summer | summer_r | tab10 | tab10_r | tab20 | tab20_r |
tab20b | tab20b_r | tab20c | tab20c_r | terrain | terrain_r |
turbo | turbo_r | twilight | twilight_r | twilight_shifted | twilight_shifted_r |
viridis | viridis_r | winter | winter_r |
到了这里,关于使用python绘制3d玫瑰花送给女朋友的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!