bar()柱形图
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
mpl.rcParams['axes.unicode_minus']=False
x = list(range(1,11))
y = np.random.randn(10)
plt.bar(x,y,align='center',color='c',tick_label= [chr(i) for i in range(65, 75)])
plt.xlabel('sample no')
plt.ylabel('value')
plt.show()
python基本绘图-统计图
barh()条形图
x = [chr(i) for i in range(65, 75)]
y = [round(abs(i)*10) for i in np.random.randn(10)]
plt.barh(x,y,align='center',color='c')
plt.show()
python基本绘图-统计图
hist()直方分布图
x = np.random.randint(0,10,100)
bins = range(0,11)
plt.hist(x,bins=bins,color='y',histtype='bar',rwidth=1)
plt.show()
python基本绘图-统计图
pie()饼图|
kinds = [chr(i) for i in range(65,75)]
soldNums = [i for i in np.random.randint(0,30,10)]
plt.pie(sorted(soldNums),labels=kinds,autopct='%3.2f%%',startangle=45)
plt.show()
python基本绘图-统计图
polar()雷达图
barSlices = 15
theta = np.linspace(0,2*np.pi,barSlices,endpoint=False)
r = 30*np.random.rand(barSlices)
plt.polar(theta,r,color='chartreuse',linewidth=2,marker='.',mfc='b',ms=10)
plt.show()
python基本绘图-统计图
scater()气泡图
x = np.random.randn(100)
y = np.random.randn(100)
plt.scatter(x,y,s=np.power(5*x+7*y,2),c=np.random.rand(100),cmap=mpl.cm.RdYlBu,marker='o')
plt.show()
python基本绘图-统计图
stem()棉棒图
x = np.linspace(.1,2*np.pi,30)
y = np.random.randn(30)
plt.stem(x,y,linefmt='-.',markerfmt='.',basefmt='-')
plt.show()
python基本绘图-统计图
boxplot()箱线图
x = np.random.randn(1000)
plt.boxplot(x)
plt.xticks([1],['random iter'])
plt.ylabel('random number')
plt.title('randomiter capacity of resisting disturbarice')
plt.grid(axis='y',ls=':',lw=2,color='gray',alpha=.5)
plt.show()
python基本绘图-统计图
errorbar()误差棒图
x = np.linspace(.01,.7,10)
y = np.exp(x)
plt.errorbar(x,y,fmt='bo:',yerr=.2,xerr=.02)
plt.show()
python基本绘图-统计图