Jouni K. Seppänen wrote: > "Mika Orajärvi" <[EMAIL PROTECTED]> 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. >
I think it is already fixed. This works (drawing a sensible bar plot with a log scale despite bins with zero): In [3]:hist(rand(10), log=True) Out[3]: (array([1, 0, 3, 1, 0, 1, 2, 1, 0, 1]), array([ 0.00863515, 0.10200932, 0.19538349, 0.28875767, 0.38213184, 0.47550601, 0.56888018, 0.66225435, 0.75562852, 0.84900269]), <a list of 10 Patch objects>) Eric ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users