logaritmic histogram

    Hallo, I have (another) simple question. How can I make

    > logaritmic histogram? If I use ( X is an array of input
    > data ):

    > from pylab import * logX = log10( X ) n, bins, patches =
    > hist( logX, 50 ) show()

    > I must take a special care for x-axis labels. Is possible to
    > use semilogx()? How?

Just set the xscale attribute for the axes to be 'log' (and make sure
you have strictly positive data, of course)

ax = subplot(111, xscale='log')
ax.hist(X, 100)

JDH

It works. Thanke you very mych. But if I want to set logaritmic Y-axes
also:

    ax = subplot(111, xscale='log', yscale='log' )

I get:

    Traceback (most recent call last):
      File "bin/plot_msg_len_dist.py", line 22, in ?
        savefig( 'smith_msg_length_dist.png' )
      File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 791,
    in savefig
        return fig.savefig(*args, **kwargs)
      File "/usr/lib/python2.4/site-packages/matplotlib/figure.py", line
    645, in savefig
        self.canvas.print_figure(*args, **kwargs)
      File
    "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py",
    line 93, in print_figure
        try: agg.print_figure(filename, dpi, facecolor, edgecolor,
    orientation)
      File
    "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py",
    line 445, in print_figure
        self.draw()
      File
    "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py",
    line 382, in draw
        self.figure.draw(renderer)
      File "/usr/lib/python2.4/site-packages/matplotlib/figure.py", line
    520, in draw
        for a in self.axes: a.draw(renderer)
      File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1402,
    in draw
        a.draw(renderer)
      File "/usr/lib/python2.4/site-packages/matplotlib/patches.py", line
    127, in draw
        tverts = self._transform.seq_xy_tups(verts)
    ValueError: Domain error on nonlinear Transformation::seq_xy_tups
    operator()(thisx, thisy)
    make: *** [smith_msg_length_dist.png] Error 1

PS: 'X' contais whole nubers >= 1.

···

On Tue, Dec 20, 2005 at 07:16:33PM -0600, John Hunter wrote:

Just set the xscale attribute for the axes to be 'log' (and make sure
you have strictly positive data, of course)

ax = subplot(111, xscale='log')
ax.hist(X, 100)

--
JP