七夕就要来了,不论你是不是一个人,都祝你开心快乐啊 代码: from matplotlib import pyplot as plt import matplotlib . animation as animation import numpy as np t = np . linspace ( 0 , 6 , 100 ) x = 16 * np . sin ( t
七夕就要来了,不论你是不是一个人,都祝你开心快乐啊
代码:
from matplotlib import pyplot as pltimport matplotlib.animation as animation
import numpy as np
t = np.linspace(0, 6, 100)
x = 16 * np.sin(t) ** 3
y = 13 * np.cos(t) - 5 * np.cos(2 * t) - 2 * np.cos(3 * t) - np.cos(4 * t)
data = [i for i in zip(x, y)]
"""
* @Author: xiaofang
学习中遇到问题没人解答?小编创建了一个Python学习交流QQ群:732481539
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
"""
def plot_love(data):
x, y = data
plt.scatter(x, y, 60, c="r", alpha=0.7, marker=r"$\heartsuit$")
fig = plt.figure(figsize=(5, 3), dpi=100)
plt.axis("off")
animator = animation.FuncAnimation(fig, plot_love, frames=data, interval=80)
animator.save("love.gif", writer='pillow')
效果: