2

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?

Community
  • 1
  • 1
Py-ser
  • 1,860
  • 9
  • 32
  • 58
  • Your example seems to render fine for me. Which version of matplotlib are you using? – ali_m Apr 21 '14 at 16:45
  • Please note that the code I reported is only a quote from the linked discussions. As I said, my values and the range where I want to plot them are very different from the example. – Py-ser Apr 22 '14 at 00:54

0 Answers0