Python 绘制简单的折线图

import matplotlib.pyplot as plt  
from pylab import *
"""
绘制简单的折线图
"""
x1 = [1, 2, 5]  
y1 = [28.40,30.61,33.66]

x2 = [1.75, 2.7, 5.9]  
y2 = [28.53,30.28,32.45] 

x3 = [1.9, 2.98, 5.1]  
y3 = [29.49,31.41,33.60]  

plt.title('H264(b) vs TTG(r) vs BPG(g)')  
plt.xlabel('Mbps')  
plt.ylabel('Average psnr')  

plt.plot(x1, y1,'b', label='H264')  
plt.plot(x2, y2,'r',label='TNG')  
plt.plot(x3, y3,'g',label='BPG')  

# 设置横轴的上下限
xlim(1.0,7.0)

# 设置横轴记号
xticks(np.linspace(1,7,6,endpoint=True))

# 设置纵轴的上下限
ylim(28.0,34.0)

# 设置纵轴记号
yticks(np.linspace(28,34,4,endpoint=True))

plt.grid()  
plt.show()