问题
here is the data:
111, 3
122, 4
155, 3
192, 5
11, 9
123, 10
120, 23
now how could I able to plot a histogram using this two set of data in matplotlib.
please help.
回答1:
You can create a barchart like this:
from matplotlib.pyplot import *
x = [111,122,155,192,11,123,120,]
y = [3,4,3,5,9,10,23]
bar(x,y)
show()
gives:
Using hist() bins your data for you, so you would pass it your raw data, ie. it would look like this:
data = [111, 111, 111, 122, 122, 122, 122, 155, ...]
来源:https://stackoverflow.com/questions/10512425/using-matplotlib-how-could-i-plot-a-histogram-with-given-data-in-python