I am trying to plot the histogram of an array elements. These elements values span over 10 orders (from 10^-10
to 1
). However, the range in which I am really interested is only 10^-10 - 10^-5
.
So I was thinking to plot the histogram on a log x-axis. I followed these two discussions here and here.
In the first case:
import pylab as pl
import numpy as np
data = np.random.normal(size=10000)
pl.hist(data, bins=np.logspace(0.1, 1.0, 50))
pl.gca().set_xscale("log")
the plot is not rendered. The axis are showed clearly but no histogram appears on the plot.
If I substitute the bins=np.logspace(0.1, 1.0, 50)
with a simple value, let's say 100
, the plot is showed correctly.
In the second discussion:
plt.xscale('log', nonposy='clip')
I don't know how to specify the number of bins in the selected x-range: the software automatically spread the specified number of bins over the whole range of values in the array.
What am I missing?