One 、 Rose painting — Deep red
Two 、 Rose painting — colorful
3、 ... and 、 Rose painting — Pink
Four 、 Rose painting — Red
5、 ... and 、 Peach blossom drawing
One 、 Rose painting — Deep redimport numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dfig = 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 * 30 * np.pi - 4*np.pi)p = (np.pi / 2) * np.exp(-t / (8 * np.pi))change = np.sin(20*t)/50u = 1 - (1 - np.mod(3.3 * t, 2 * np.pi) / np.pi) ** 4 / 2 + changey = 2 * (x ** 2 - x) ** 2 * np.sin(p)r = u * (x * np.sin(p) + y * np.cos(p)) * 1.5h = u * (x * np.cos(p) - y * np.sin(p))c= plt.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)plt.show()
Two 、 Rose painting — colorful import numpy as npimport matplotlib.pyplot as pltfrom matplotlib import cmfrom mpl_toolkits.mplot3d import Axes3Dfig = 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))h = u * (x * np.cos(p) - y * np.sin(p))c= cm.gist_rainbow_rsurf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap= c, linewidth=0, antialiased=True)plt.show()
3、 ... and 、 Rose painting — Pink import numpy as npimport matplotlib.pyplot as pltfrom matplotlib import cmfrom mpl_toolkits.mplot3d import Axes3Dfig = 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))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)plt.show()
Four 、 Rose painting — Red # Header file omitted , You can see in the previous blog import numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dfig = plt.figure()ax = fig.gca(projection='3d')# Moved the phase back 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))# Add edge perturbation change = np.sin(15*t)/150# take t The number of parameters is reduced , Increase the angle of the petals u = 1 - (1 - np.mod(3.3 * t, 2 * np.pi) / np.pi) ** 4 / 2 + changey = 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= plt.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)plt.show()
5、 ... and 、 Peach blossom drawing import numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dfig = 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 * 6 * np.pi - 4*np.pi)p = (np.pi / 2) * np.exp(-t / (8 * np.pi))change = np.sin(10*t)/20u = 1 - (1 - np.mod(5.2 * t, 2 * np.pi) / np.pi) ** 4 / 2 + changey = 2 * (x ** 2 - x) ** 2 * np.sin(p)r = u * (x * np.sin(p) + y * np.cos(p)) * 1.5h = u * (x * np.cos(p) - y * np.sin(p))c= plt.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)plt.show()
This is about python That's all for the article on drawing roses' Valentine's Day confession , More about python Please search the previous articles of SDN or continue to browse the related articles below. I hope you will support SDN more in the future !