Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make a bar chart on range of values on x-axis and count on the range on y-axis in python?

I have a list such as [0.2,0.4,1.2,2.4,5.4,6.0,0.3,3.4..] and I want to group the values in the list to a range(interval can change for different inputs) 0-1,1-2,2-3 and would like to plot a graph where the x-axis is the range and y-axis depicts the no_of_values in the given range?

For the above problem, {0-1:3,1-2:1,2-3:1,3-4:1,4-5:0,5-6:2}

Thanks in advance

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try using pandas.DataFrame.hist

pd.DataFrame(ls).hist()

where ls = [0.2,0.4,1.2,2.4,5.4,6.0,0.3,3.4]

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading