美文网首页
matplotlib之直方图hist

matplotlib之直方图hist

作者: 崔吉龙 | 来源:发表于2019-03-08 11:12 被阅读0次

问题描述

当我们想展示不同的数据在所有数据样本中的分布时,需要用直方图来展示。当然在数据量很大的时候,如果为每个数据样本都展示一个分布,数据量太大,而且不利于观察,我们通常的做法是把数据打散成一个个的小段,每个小段代表数据范围的一个子集。
下面使用随机数据来创建一个直方图。

直方图的例子

import numpy as np
import matplotlib.pyplot as plt

x = 20 * np.random.randn(10000)
plt.hist(x, 25, range=(-50, 50), histtype='stepfilled', align='mid', color='g', label='Test Data')
plt.legend()
plt.title('Step Filled Histogram')
plot_004.png

相关文章

网友评论

      本文标题:matplotlib之直方图hist

      本文链接:https://www.haomeiwen.com/subject/eyxeeqtx.html