0

i try to plot data in a histogram or bar in python. The data size (array size) is between 0-10000. The data itself (each entry of the array) depends on the input and has a range between 0 and e+20 (mostly the data is in th same range). So i want to do a hist plot with matplotlib. I want to plot how often a data is in some intervall (to illustrate the mean and deviation). Sometimes it works like this: hist1. But sometimes there is a problem with the intevall size like this: hist2. In this plot i need more bars at point 0-100 etc. Can anyone help me with this?

The plots are just made with:

from numpy.linalg import * import matplotlib.pyplot as plt plt.hist(numbers,bins=100) plt.show() 

1 Answer 1

3

By default, hist produces a plot with an x range that covers the full range of your data. If you have one outsider at very high x in comparison with the other values, then you will see this image with a 'compressed' figure.

I you want to have always the same view you can fix the limits with xlim.
Alternatively, if you want to see your distribution always centered and as nicer as possible, you can calculate the mean and the standard deviation of your data and fix the x range accordingly (p.e. for mean +/- 5 stdev)

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.