标签:
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
标签:
原文地址:http://www.cnblogs.com/chauncy/p/5566369.html