# python画图初体验[matplotlib/pylab]

import pylab as pl
import matplotlib.pyplot as plt

import numpy as np
import matplotlib.pyplot as plt

plt.plot(x,y,format_string,**kwargs)#应该是最常用的

'''
matplotlib.pyplot
pylab]

'''
import numpy as np
import pylab as pl
import matplotlib.pyplot as plt

#散点图
np.random.seed(0)  #随机数生成后不变
x = np.r_[np.random.randn(20,2)-[2,2],np.random.randn(20,2)+[2,2]]
#pl.plot(x[:,0],x[:,1])
y = [1]*20 + [0]*20

pl.subplot(311)　＃区域画图
pl.scatter(x[:,0],x[:,1],c = y,cmap=pl.cm.Paired)
#pl.axis("tight")

pl.subplot(312)
t = np.arange(-1,2,.01)
s = np.sin(2*np.pi*t)
pl.axis([-1,2,-1,1])
pl.plot(t,s,'y--')
l = pl.axhline(linewidth = 2,color ='k')
l = pl.axvline(x=0,ymin=0,linewidth = 4,color='b')
p = pl.axhspan(0.25,0.75,facecolor='g',alpha=0.5)
p = pl.axvspan(1.25,1.55,facecolor='r',alpha=0.5)

pl.ylabel("纵轴",fontproperties='SimHei',fontsize=10) #设置 纵坐标标记，中文显示
pl.xlabel("横轴",fontproperties='SimHei',fontsize=10)

pl.subplot(313)
pl.scatter(10*np.random.randn(10),10*np.random.randn(10))

pl.show()


'''

'''
import matplotlib.pyplot as plt
import numpy as np

plt.subplot(211)

labels ='Frogs','Hogs','Dogs','Logs'
sizes = [15,30,45,10]

explode = (0,0.1,0,0)
plt.pie(sizes,explode=explode,labels =labels,autopct="%1.1f%%",

plt.subplot(212)
np.random.seed(0)
mu,sigma=100,20  #均值和标准差

a = np.random.normal(mu,sigma,size=100)

plt.hist(a,40,normed=1,histtype='stepfilled',facecolor='b',alpha=0.75)
plt.title('Histogram')

plt.show()