# coding=utf-8
from matplotlib import pyplot as plt
from matplotlib import font_manager a=[131, 98, 125, 131, 124, 139, 131, 117, 128, 108, 135, 138, 131, 102, 107, 114, 119, 128, 121, 142, 127, 130, 124, 101, 110, 116, 117, 110, 128, 128, 115, 99, 136, 126, 134, 95, 138, 117, 111,78, 132, 124, 113, 150, 110, 117, 86, 95, 144, 105, 126, 130,126, 130, 126, 116, 123, 106, 112, 138, 123, 86, 101, 99, 136,123, 117, 119, 105, 137, 123, 128, 125, 104, 109, 134, 125, 127,105, 120, 107, 129, 116, 108, 132, 103, 136, 118, 102, 120, 114,105, 115, 132, 145, 119, 121, 112, 139, 125, 138, 109, 132, 134,156, 106, 117, 127, 144, 139, 139, 119, 140, 83, 110, 102,123,107, 143, 115, 136, 118, 139, 123, 112, 118, 125, 109, 119, 133,112, 114, 122, 109, 106, 123, 116, 131, 127, 115, 118, 112, 135,115, 146, 137, 116, 103, 144, 83, 123, 111, 110, 111, 100, 154,136, 100, 118, 119, 133, 134, 106, 129, 126, 110, 111, 109, 141,120, 117, 106, 149, 122, 122, 110, 118, 127, 121, 114, 125, 126,114, 140, 103, 130, 141, 117, 106, 114, 121, 114, 133, 137, 92,121, 112, 146, 97, 137, 105, 98, 117, 112, 81, 97, 139, 113,134, 106, 144, 110, 137, 137, 111, 104, 117, 100, 111, 101, 110,105, 129, 137, 112, 120, 113, 133, 112, 83, 94, 146, 133, 101,131, 116, 111, 84, 137, 115, 122, 106, 144, 109, 123, 116, 111,111, 133, 150] #计算组数
d = 3 #组距
num_bins = (max(a)-min(a))//d
print(max(a),min(a),max(a)-min(a))
print(num_bins) #设置图形的大小
plt.figure(figsize=(20,8),dpi=80)
plt.hist(a,num_bins,normed=True) #设置x轴的刻度
plt.xticks(range(min(a),max(a)+d,d)) plt.grid() plt.show()

显示效果

4.matplotlib绘制直方图的更多相关文章

  1. NumPy使用 Matplotlib 绘制直方图

    NumPy - 使用 Matplotlib 绘制直方图 NumPy 有一个numpy.histogram()函数,它是数据的频率分布的图形表示. 水平尺寸相等的矩形对应于类间隔,称为bin,变量hei ...

  2. matplotlib绘制直方图【柱状图】

    代码: def drawBar(): xticks = ['A', 'B', 'C', 'D', 'E']#每个柱的下标说明 gradeGroup = {'A':200,'B':250,'C':330 ...

  3. 关于matplotlib绘制直方图偏移的问题

    在使用pyplot绘制直方图的时候我发现了一个问题,在给函数.hist()传参的时候,如果传入的组数不是刚刚好(就是说这个组数如果是使用(最大值-最小值)/组距计算出来,而这个数字不是整除得来而是取整 ...

  4. Python:matplotlib绘制直方图

    使用hist方法来绘制直方图:     绘制直方图,最主要的是一个数据集data和需要划分的区间数量bins,另外你也可以设置一些颜色.类型参数: plt.hist(np.random.randn(1 ...

  5. numpy和matplotlib绘制直方图

    使用 Matplotlib Matplotlib 中有直方图绘制函数:matplotlib.pyplot.hist()它可以直接统计并绘制直方图.你应该使用函数 calcHist() 或 np.his ...

  6. 利用pandas读取Excel表格,用matplotlib.pyplot绘制直方图、折线图、饼图

    利用pandas读取Excel表格,用matplotlib.pyplot绘制直方图.折线图.饼图 数据: 折线图代码: import  pandas  as pdimport  matplotlib. ...

  7. matplotlib如何绘制直方图、条形图和饼图

    1 绘制直方图: import matplotlib.pyplot as plt import numpy as np import matplotlib def hist1(): # 设置matpl ...

  8. python包matplotlib绘制图像

    使用matplotlib绘制图像 import matplotlib.pyplot as plt from matplotlib.pyplot import MultipleLocator impor ...

  9. matplotlib绘制动画

    matplotlib从1.1.0版本以后就开始支持绘制动画,具体使用可以参考官方帮助文档.下面是一个很基本的例子: """ A simple example of an ...

随机推荐

  1. easyui datagrid的editor编辑器如何为validatebox控件添加改变事件

    项目中需要为行编辑器Editor的某个列的文本框添加改变事件 需求:新增行时,为用户名输入特殊字符进行验证,不允许保存用户数据 html页面 <table id="gridlist&q ...

  2. Sketch2Code - Transform sketches into HTML using AI

    Sketch2Code - Transform sketches into HTML using AI https://sketch2code.azurewebsites.net/generated- ...

  3. MQTT研究之EMQ:【EMQX使用中的一些问题记录(3)】

    EMQX功能强大,但是帮助信息或者可用资料的确有限,遇到个问题,比较难找到处理的头绪,今天,我要记录的是,使用中出现EMQX宕机,但是呢,启动也启动不了. 今天记录的内容,就以操作EMQX 3.2.3 ...

  4. Python3基础 tuple 使用通配符*进行拆包 简单示例

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  5. (原创)C++半同步半异步线程池2

    (原创)C++半同步半异步线程池 c++11 boost技术交流群:296561497,欢迎大家来交流技术. 线程池可以高效的处理任务,线程池中开启多个线程,等待同步队列中的任务到来,任务到来多个线程 ...

  6. Consider defining a bean of type 'com.*.*.mapper.*.*Mapper' in your configuration.

    @Mapper 不能加载的问题 Consider defining a bean of type 'com.*.*.mapper.*.*Mapper' in your configuration. 添 ...

  7. SpringCloud学习笔记-Eureka基础

    Spring Cloud Eureka是Spring Cloud Netflix微服务套件中的一部分,它基于Netflix Eureka做了二次封装,主要负责完成微服务架构中的微服务治理功能. 服务端 ...

  8. k8s记录-k8s基本概念和术语

    每次个节点上当然都要运行Docker.Docker来负责所有具体的映像下载和容器运行. Kubernetes主要由以下几个核心组件组成: etcd保存了整个集群的状态: apiserver提供了资源操 ...

  9. pan wutong团队隐私协议

    本隐私权政策详细说明了pan wutong团队(“我们”或“我们的”)通过我们的应用程序和网站收集的信息,以及我们将如何使用这些信息. 1.我们不会通过我们的应用程序或网站收集儿童的个人信息. 我们深 ...

  10. 【论文阅读】PBA-Population Based Augmentation:Efficient Learning of Augmentation Policy Schedules

    参考 1. PBA_paper; 2. github; 3. Berkeley_blog; 4. pabbeel_berkeley_EECS_homepage; 完