# encoding=utf-8 import matplotlib.pyplot as plt from pylab import * #支持中文 mpl.rcParams['font.sans-serif'] = ['SimHei'] names = ['10', '40', '60', '70', '90'] x = range(len(names)) y1 = [1,2,3,3.4,3.8] y2 = [1,2,3,3.7,4] y3 = [1,2,3,4,4.6] #pl.xlim(-1, 11) # 限定横轴的范围 plt.ylim(1,5) # 限定纵轴的范围 plt.plot(x, y1, marker='o',color='r', label=u'Dijkstra') plt.plot(x, y2, marker='*',color='g',label=u'ECMP') plt.plot(x, y3, marker='+',color='b',label=u'This paper') plt.legend() # 让图例生效 plt.xticks(x, names, rotation=45) plt.margins(0) plt.subplots_adjust(bottom=0.15) plt.xlabel(u"Load") #X轴标签 plt.ylabel("Throughput (Mb/s)") #Y轴标签 plt.title("Load and throughput") #标题 plt.show()