Matplotlib.pyplot 常用方法(二)

本文详细介绍了Matplotlib.pyplot中的hist()和pie()函数,包括参数含义和使用方法。hist()函数用于绘制直方图,重点讲解了如何控制bin数量、范围、正则化等特性。pie()函数则用于创建饼图,讨论了颜色、标签、比例显示和阴影效果等选项。这两个函数是Python数据可视化中常用的方法。
摘要由CSDN通过智能技术生成

hist()——直方图

n, bins, patches = hist (x, bins=10, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype=’bar’, align=’mid’, orientation=’vertical’, rwidth=None, log=False, color=None, label=None, stacked=False, hold=None, data=None, **kwargs)

参数的意义:

  • x : (n,) array or sequence of (n,) arrays,表示:就是输入的数据啦,可以为一个序列数,也可以多组;

  • bins : integer or array_like, 表示:控制分的块数,要分的块数为bins,默认为10;

  • range : tuple or None, optional, 表示画图的范围大小 ;详细你们看英语哈;

The lower and upper range of the bins. Lower and upper outliers are ignored. If not provided, range is (x.min(), x.max()). Range has no effect if bins is a sequence.

If bins is a sequence or range is specified, autoscaling is based on the specified bin range instead of the range of x.

Default is None

  • normed : boolean, optional, 意义就是说,返回的第一个n(后面解释它的意义)吧,把它们正则化它,让bins的值 的和为1,这样差不多相当于概率分布似的了;

If True, the first element of the return tuple will be the counts normalized to form a probability density, i.e., n/(len(x)`dbin), i.e., the integral of the histogram will sum to 1. If stacked is also True, the sum of the histograms is normalized to 1.

Default is False

  • weights : (n, ) array_like or None, optional 啥意义啊,不知道 哦

An array of weights, of the same shape as x. Each value in x only contributes its associated weight towards the bin count (instead of 1). If normed is True, the weights are normalized, so that the integral of the density over the range remains 1.

Default is None

  • cumulative : boolean, optional ,就是每一列都把之前的加起来,可能这么说不严谨哦,不过就是那个意思;

If True, then a histogram is computed where each bin gives the counts in that bin plus all bins for smaller values. The last bin gives the total number of datapoints. If normed is also True then the histogram is normalized such that the last bin equals 1. If cumulative evaluates to less than 0 (e.g., -1), the direction of accumulation is reversed. In this case, if normed is also True, then the histogram is normalized such that the first bin equals 1.

Default is Fal

  • bottom : array_like, scalar, or None,下面的每个bin的基线,表示bin的值都从这个基线上往上加;

Location of the bottom baseline of each bin. If a scalar, the base line for each bin is shifted by the same amount. If an array, each bin is shifted independently and the length of bottom must match the number of bins. If None, defaults t

Default is None<

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值