Matplotlib:频率列表中的直方图 [英] Matplotlib: Histogram from a list of frequencies
本文介绍了Matplotlib:频率列表中的直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个列表x = [90,100,121,123,88].列表中的这些值是5种不同试验中事件发生的频率.我正在寻找从此列表创建直方图.
I have a list x = [90, 100, 121, 123, 88]. These values in the list are frequencies of occurrence of an event in 5 different trials. I am looking to create a histogram from this list.
我只是尝试过:
plt.hist(x)
plt.show()
我明白了:
我需要这样的东西:
注意:Python的新手.并且仍在学习何时以及如何使用Stackoverflow.
Note: Very New to Python. And still learning when and how to use Stackoverflow.
推荐答案
由于列表 x
包含频率,因此请使用条形图:
Since the list x
contains the frequencies then use a bar plot:
x = [90, 100, 121, 123, 88]
plt.bar(range(1,6), x)
plt.ylabel('frequency')
plt.show()
这篇关于Matplotlib:频率列表中的直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文