Skip to content
Advertisement

Matplotlib histogram where bins are defined range of FLOATS and colored by it?

I do RMSF analysis and as a results I have list of floats (0.1, 0.3, etc.) and I would like to do a histogram where are bins of defined ranges of the floats. Then I want to have each range of float with corresponding color. I tried to do it with analogies of this script:

JavaScript

I know that there is problem with the float and tried to fix it with numpy and np.arange, but of course it is not so easy for me as I am new to python. Any suggestion, please?

Advertisement

Answer

You would want to pass bins into ax.hist:

JavaScript

Output:

enter image description here

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement