其他
妖气的小心心
主要函数为y = x^(2/3) + 0.9 * (b - x^2)^0.5 * sin(a * pi * x)。
#coding=utf-8
#Python
import numpy as np
import sys
import PlotUtil
def plotFunc(plt, handle, data):
x = data[1]
y = data[2]
a = data[0]
h = handle.plot(x, y, color = 'r')
plt.ylim(-2, 3)
plt.xlim(-3, 3)
handle.axis('off')
return h
def plotLoveHeart():
datas = []
a = 5.2
while True:
print(a)
if a > 28:
break
x = np.linspace(-2, 2, 5000)
y = np.abs(x) ** (2 / 3.0) + 0.9 * (4 - x ** 2) ** 0.5 * np.sin(a * np.pi * x)
datas.append([a, x, y])
a += 0.2
filename = "loveHeart.gif"
plot = PlotUtil.Plot(datas, plotFunc)
plot.showGif(filename)
if __name__ == '__main__':
plotLoveHeart()
02展示结果展示