zoukankan      html  css  js  c++  java
  • 柱状图

    import pandas as pd
    import matplotlib.pyplot as plt
    
    students=pd.read_excel('c:/Temp/Students.xlsx')
    
    students.sort_values(by = 'Number',inplace= True ,ascending= False)
    
    #sort_values 排序
    #以Numberi排序
    # inplace=True:不创建新的对象,直接对原始对象进行修改;
    # inplace=False:对数据进行修改,创建并返回新的对象承载其修改结果
    # ascending是否正序排
    
    
    students.plot.bar(x='Field',y='Number',color='orange',title= "intertional students field")   #Field为 x轴   Number为Y轴
    print (students)
    
    plt.show()  #展示图
    import pandas as pd
    import matplotlib.pyplot as plt
    
    students=pd.read_excel('c:/Temp/Students.xlsx')
    
    students.sort_values(by = 'Number',inplace= True ,ascending= False)
    
    #sort_values 排序
    #以Numberi排序
    # inplace=True:不创建新的对象,直接对原始对象进行修改;
    # inplace=False:对数据进行修改,创建并返回新的对象承载其修改结果
    # ascending是否正序排
    
    
    # students.plot.bar(x='Field',y='Number',color='orange',title= "intertional students field")   #Field为 x轴   Number为Y轴
    
    plt.bar(students.Field,students.Number,color='orange')
    plt.xticks(students.Field,rotation='90')   #Field 标签旋转90
    print (students)
    plt.xlabel('Field')
    plt.ylabel('Number')
    plt.title('intertional students field',fontsize=16)
    
    #x轴名称,y轴名称,标题及字号
    
    plt.tight_layout()  #紧凑型视图
    plt.show()  #展示图
  • 相关阅读:
    Chrome使用指南
    Vue2.x-踩坑记
    C# WinForm listView 多行删除 操作
    Winform中DataGridView多行删除
    20211026_阿里云服务器引流限制ssl的问题
    docker commit
    docker build
    docker build与docker commit
    阿里云Docker镜像仓库(Docker Registry)
    Docker Nginx安装(centos7)
  • 原文地址:https://www.cnblogs.com/inserence/p/10995604.html
Copyright © 2011-2022 走看看