Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using matplotlib how could I plot a histogram with given data in python

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.

like image 885
diffracteD Avatar asked Aug 14 '26 09:08

diffracteD


1 Answers

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: enter image description here 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, ...]
like image 102
fraxel Avatar answered Aug 16 '26 21:08

fraxel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!