matplotlib应用
1 #-*- coding:utf-8 -*- 2 # 3 import numpy as np 4 import matplotlib.pyplot as plt 5 6 x = np.linspace(0,10,1000) 7 y = np.sin(x)+1 8 z = np.cos(x**2)+1 9 10 plt.figure(figsize=(8,4)) 11 plt.plot(x,y,label = '$\sin x+1$',color = 'red',linewidth=2) 12 plt.plot(x,z,'b--',label = '$\cos x^2+1$') 13 plt.xlabel('Time(s)') 14 plt.ylabel('Volt') 15 plt.title('A Simple Example') 16 plt.ylim(0,2.2) 17 plt.legend() 18 plt.show()
matplotlib是数据分析时常用的作图代码,此例中依赖上级库numpy
posted on 2016-06-07 11:23 Chauncy要记得有梦想 阅读(209) 评论(0) 收藏 举报
浙公网安备 33010602011771号