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()  #展示图
  • 相关阅读:
    Ruby(1):入门
    html 制作静态页面新知识
    mysql 可视化界面操作指令
    html 基础
    Eclipse导入Java工程导入错误
    shell 25个常用命令
    java JDBC
    java 8新特性 instant
    git
    spring mvc 注解详解
  • 原文地址:https://www.cnblogs.com/inserence/p/10995604.html
Copyright © 2011-2022 走看看