import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
% matplotlib inline
from matplotlib.pyplot import *
1.直方图
x=np.arange(0,10,1)
y=np.log(x)
xe=0.1*np.abs(np.random.randn(len(y)))
plt.bar(x,y,yerr=xe,align='center',ecolor='r',color='cyan',label='experiment#1')
plt.xlabel('year')#添加x轴的标签
plt.ylabel('age')#添加y轴的标签
plt.title('This is title')#添加标题
plt.legend(bbox_to_anchor=(-0.01,1,1,0),ncol=3,loc='upper left')#控制图例的位置,legend图例的默认描述与label的相同experiment#1
plt.gca().xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(1))#控制X轴的标签为1的整数倍

2.饼图
figure(figsize=(6,6))
ax=axes([0.1,0.1,0.8,0.8])#建立轴的大小