matplotlib hist() autocropping range

Actually, it works if you specify with range an interval shorter than [-100, 100]. For example, this work :

import numpy as np
import matplotlib.pyplot as plt

x = np.random.uniform(-100, 100, 1000)
plt.hist(x, bins=30, range=(-50, 50))
plt.show()

If you want to plot the histogram on a range larger than [x.min(), x.max()] you can change xlim propertie of the plot.

import numpy as np
import matplotlib.pyplot as plt

x = np.random.uniform(-100, 100, 1000)
plt.hist(x, bins=30)
plt.xlim(-500, 500)
plt.show()