目录

前言

今天我们学习的是直方图,导入的函数是:

plt.hist(x=x, bins=10) 与plt.hist2D(x=x, y=y)

(一)直方图

(1)说明:

pyplot.``hist(x, bins=None, density=None,……kwargs*)

常见的参数属性

具体参考:官网说明文档

属性 说明 类型
x 数据 数值类型
bins 条形数 int
color 颜色 "r","g","y","c"
density 是否以密度的形式显示 bool
range x轴的范围 数值元组(起,终)
bottom y轴的起始位置 数值类型
histtype 线条的类型 "bar":方形,"barstacked":柱形,
"step":"未填充线条"
"stepfilled":"填充线条"
align 对齐方式 "left":左,"mid":中间,"right":右
orientation orientation "horizontal":水平,"vertical":垂直
log 单位是否以科学计术法 bool

(2)源代码:

# 导入模块
import matplotlib.pyplot as plt
import numpy as np # 数据
mu = 100 # 均值
sigma = 20 # 方差
# 2000个数据
x = mu + sigma*np.random.randn(2000) # 画图 bins:条形的个数, normed:是否标准化
plt.hist(x=x, bins=10) # 展示
plt.show()

(3)输出效果:

默认:y轴是个数

改:plt.hist(x=x, bins=10, density=True)

y轴是频率

(二)双直方图

(1)说明:

pyplot.``hist2d(x, y, bins=10, **kwargs)

常见的参数属性

具体参考:官网说明文档

x x坐标
y y坐标
bins 横竖分为几条

(2)源代码:

# 导入模块
import matplotlib.pyplot as plt
import numpy as np # 数据
x = np.random.randn(1000)+2
y = np.random.randn(1000)+3 # 画图
plt.hist2d(x=x, y=y, bins=30) # 展示
plt.show()

(3)输出效果:

作者:Mark

日期:2019/02/13 周三

最新文章

  1. 2016huasacm暑假集训训练四 递推_B
  2. 关于<textArea>控件下显示不出其它控件
  3. MAT(Memory Analyzer Tool)工具入门介绍
  4. poj 1328
  5. Add SSH Key to GitLab on Windows
  6. 恶补web之六:javascript知识(1)
  7. anaconda相关使用方法
  8. docker-跨主机存储
  9. windows 控制台下运行cl命令
  10. python shelve模块
  11. spring 如何决定使用jdk动态代理和cglib(转)
  12. google pay app权限使用说明
  13. redis 的set数据类型
  14. DWZ学习记录--关闭loading效果
  15. AsycnTask
  16. C# 转义字符 '\'反斜杠
  17. 深夜配置一把struts2
  18. Linux命令--权限管理
  19. Maven 配置Tomcat
  20. openstack如何整合vmare最佳方案

热门文章

  1. Go基础系列:函数(1)
  2. Go基础系列:函数(2)——回调函数和闭包
  3. meterpreter持久后门
  4. [转]js 取得 Unix时间戳(Unix timestamp)
  5. WPF BackGroundWord 异步加载更新进度条示例
  6. 7.QT-Qt对象间的父子关系
  7. 蓝桥杯试题----- 打印大X
  8. java package(包)的用法
  9. Js 控制随机数概率
  10. xhr post请求