1

I am plotting a histogram with this data.

dict_values([2.5039286220812003e-18, 8.701119009863531e-17, 9.181036322384948e-17, 8.972473923736572e-17, 9.160265320730097e-17, 8.826609291023463e-17, 8.888913336226638e-17, 8.993242948900264e-17, 9.556623462346049e-17, 8.847279448923369e-17, 8.86804710730486e-17, 8.806035948033239e-17])

This is my code:

print(len(new_dictonary.values()))
plt.figure(figsize=(15, 5))
plt.hist(new_dictonary.values())
plt.show()

I expect to have 12 bar, but I got only two bars. I have to use plt.hist enter image description here

How could correct my code to have the right picture?

1 Answer 1

2

Edited answer: The problem is that your values are very small in magnitude and 11 out of 12 are very close to each other and the remaining one is far away. So to have each value plotted individually as a separate bar, you need a large number of bins. Now if you limit your x-axis to show the 11 similar values out of 12, you will see that having bins=1000 (a large number) shows 11 bars.

plt.hist(new_dictonary, bins=1000, edgecolor='k')
plt.xlim(0.8e-16, 1e-16)

enter image description here

If you show them all, you will see how far they are. I don't know how you plan to fit a distribution to such data.

plt.hist(new_dictonary, bins=1000, edgecolor='k')

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

I need an histogram. In fact I want to plot distribution curve over this histogram.
Then you need to specify bins accordingly so as to have 12 bars. Your values are unequally spaced. In fact 11 of them are close and 1 is far away. So you need a large number of bins so that each value appears as a bar
thank you very much for your help. You put an important point: how I plan to fit a distribution for such data. In fact, I hope that you can help me in this point. I need to extract the confidential interval for my data. I am not sure what to do exactly. But I feel that the first thing to do is to analyze my data distribution. but for many cases I found that Theoretical values pdf in my interval is equal to [nan]. so I feel that I am lost. I would be very grateful for your help really

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.