用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%%')

用matplotlib统计数据并画图

相关文章:

  • 2021-05-16
  • 2021-06-27
  • 2021-09-05
猜你喜欢
  • 2021-12-20
  • 2021-10-22
  • 2021-09-19
  • 2022-01-20
  • 2021-07-05
  • 2022-12-23
  • 2021-03-29
相关资源
相似解决方案