GIF(Graphics Interchange Format,图形交换格式)是一种位图图像格式,
GIF格式的图像文件具有如下特点:
(1)GIF格式图像文件的扩展名是“.gif”。
(2)对于灰度图像表现最佳。
(3)具有GIF87a和GIF89a两个版本。
(4)采用改进的LZW压缩算法处理图像数据。
(5)调色板数据有通用调色板和局部调色板之分,有不同的颜色取值。
(6)不支持24bit彩色模式,最多存储256色。matplotlib
matplotlib中的animation模块绘制动态图,绘制心形动态函数
安装matplotlib
pip install matplotlib
代码实现:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
# fig.patch.set_alpha(0.) # 设置透明背景,但animation不起作用
plt.axis('off') # 关闭坐标轴
#初始化窗口和坐标轴
xdata, ydata = [], []
#初始化x,y列表
ln, = ax.plot([], [], 'r-', animated=False)
#初始化绘制曲线的参数。
#init()函数初始化x,y轴范围
def init():
ax.set_xlim(-20,20)