用jupyter来统计数据,画出柱状图
import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib %matplotlib inline matplotlib.rcParams['font.sans-serif'] = ['SimHei'] data = pd.read_csv('tips.csv') result = data['sex'].value_counts() # result.plot(kind='bar',color=['red','blue']) people_count = [100,200,300,400,500] plt.figure() #出事化一个画布 plt.subplot(2,2,1) #绘制位置 plt.bar(range(5),height=people_count,color=['red','pink','blue','green','red']) plt.xticks(range(5),['A','B','C','D','E']) plt.xlabel('专业名称') plt.ylabel('数量') plt.title('专业信息') plt.plot(people_count,color='red') #线图 plt.subplot(2,2,4) plt.pie(people_count,labels=['A','B','C','D','E'],autopct='%1.1f%%')