问题
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.
I simply tried:
plt.hist(x)
plt.show()
I get this:
I need something like this:
Note: Very New to Python. And still learning when and how to use Stackoverflow.
回答1:
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()
来源:https://stackoverflow.com/questions/52857413/matplotlib-histogram-from-a-list-of-frequencies