zoukankan      html  css  js  c++  java
  • Matplotlib简介和pyplot的简单使用——直方统计图和轮廓曲线

    这次介绍pyplot如何画直方统计图,并且画出最合适的轮廓线。这是Matplotlib自带的一个例子,示例程序example/pyplot_examples/histdiagram_demo.py。
    先看效果图,

    在看代码,

    #!/usr/bin/env python
    import numpy as np
    import matplotlib.mlab as mlab
    import matplotlib.pyplot as plt
    
    mu, sigma = 100, 15
    x = mu + sigma*np.random.randn(10000)
    
    # the histogram of the data
    n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
    
    # add a 'best fit' line
    y = mlab.normpdf( bins, mu, sigma)
    l = plt.plot(bins, y, 'r--', linewidth=1)
    
    plt.xlabel('Smarts')
    plt.ylabel('Probability')
    plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
    plt.axis([40, 160, 0, 0.03])
    plt.grid(True)
    
    plt.show()

    Matplotlib很不错,不过暂时不会用到更多的功能,所以不会有更多的内容更新了。下一篇是关于输出eps格式。

  • 相关阅读:
    软件测试学习随笔(1) 引言
    集成测试
    SPM-using Maven and Juint
    验收测试
    白盒测试学习
    编码的UI测试
    测试闰年
    黑盒测试续
    黑盒测试方法-等价类划分
    对软件测试的理解
  • 原文地址:https://www.cnblogs.com/Frandy/p/python_pyplot_histdiagram.html
Copyright © 2011-2022 走看看