雪花,是世界上最圣洁的花,当你静静的倾听天籁,尘世的浮躁与喧嚣,似乎都已离你远去,剩下的惟有纯净,那是心灵忘却一切的畅然,那是在没有尘埃的世界里,生命自由呼吸的平淡与安恬。
本文实例讲述了Python基于Matplotlib库简单绘制折线图的方法。分享给大家供大家参考,具体如下:
Matplotlib画折线图,有一些离散点,想看看这些点的变动趋势:
import matplotlib.pyplot as plt x1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] y1=[30,31,31,32,33,35,35,40,47,62,99,186,480] x2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] y2=[32,32,32,33,34,34,34,34,38,43,54,69,116,271] x3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] y3=[30,31,31,32,33,35,35,40,47,62] x4 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] y4=[32,32,32,33,34,34,34,34,38,43] group_labels = ['64k', '128k','256k','512k','1024k','2048k','4096k','8M','16M','32M','64M','128M','256M','512M'] plt.title('broadcast(b) vs join(r)') plt.xlabel('data size') plt.ylabel('time(s)') #plt.plot(x1, y1,'r', label='broadcast') #plt.plot(x2, y2,'b',label='join') #plt.xticks(x1, group_labels, rotation=0) plt.plot(x3, y3,'r', label='broadcast') plt.plot(x4, y4,'b',label='join') plt.xticks(x3, group_labels, rotation=0) plt.legend(bbox_to_anchor=[0.3, 1]) plt.grid() plt.show()
离散点的走势:
希望本文所述对大家Python程序设计有所帮助。
以上就是Python基于Matplotlib库简单绘制折线图的方法示例。大多数人都只是过客和观光者,只有少数人创造者;大多数人都是梦想家,只有少数人才是实干家;藏锋,内敛,谦虚。更多关于Python基于Matplotlib库简单绘制折线图的方法示例请关注haodaima.com其它相关文章!