zoukankan      html  css  js  c++  java
  • Python 直方图

    1、示例1

    代码

    import numpy as npimport matplotlib.pyplot as plt 
    
    # 生成数据
    np.random.seed(42)
    v = np.random.normal(0, 1, 500)
    
    plt.hist(x = v, bins=20, color='k', edgecolor='gray')
    
    plt.show()

    图形

     

    2、示例2

    代码

    import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt 
    
    # 生成数据
    np.random.seed(42)
    v = np.random.normal(0, 1, 500)
    x = pd.DataFrame(v)
    
    x.hist(bins=20, color = 'b', edgecolor = 'gray', alpha = 0.7, grid = False)
    
    plt.show()

    图形

     

     。。。

  • 相关阅读:
    Java——泛型、异常
    接口
    Classes
    Unit Tests
    Boundaries
    Error Handling
    Objects and Data Structures
    DB other operation
    Comments
    Functions
  • 原文地址:https://www.cnblogs.com/shanger/p/13021502.html
Copyright © 2011-2022 走看看