From: <jk...@ik...> - 2007-02-12 15:11:31
|
"Mika Orajärvi" <mik...@gm...> writes: > This code does seem to draw some kind of histogram but it would be > much more usefull to have at least the y-scale as logarithmic. But I > haven't found a way to make the scale logarithmic. According to the docstring of hist you can give it a keyword argument of log=True to make the y axis logarithmic. However there is a slight bug in that zero-height histogram bars like you have in your example cause log(0) to be computed. Here's a quick fix: ------------------------------------------------------------------------ from pylab import * x=0.000925,0.000879,0.000926,0.00088,0.001016,0.000931,0.000927,0.00088,\ 0.000926,0.000926,0.000879,0.0009 n, bins = mlab.hist(x, 1000) width = 0.9 * (bins[1]-bins[0]) nz = nonzero(n) bar(bins[nz], n[nz], width=width, log=True) grid(True) show() ------------------------------------------------------------------------ If the devs agree that this is a bug in hist, I can fix it in svn. -- Jouni K. Seppänen http://www.iki.fi/jks |