Binning data, deleting an histogram from plot

Hi folks,

I want to bin sevaral arrays of data and superimpose them in a single plot.
The simplest approach is to fire several times

hist(data_i, N)

My problem is that I want to make a loglog plot (i.e. putting a
logscale on the X axis too, something that hist doesn't allow me to
do).

So what I've done so far is extracting the bin coordinates from
hist(data_i, N)[1], extract histogram values using hist(data_i, N)[0]
and then a loglog plot them one against each other.

The point is that I have to invoke at least once the command
hist(data_i, N) in order to do so, and this draws patches on my figure
which I don't want to appear on my final plot.

How do I delete the histogram bars? In other words, how to I delete an
entire histogram from my plot?

Other suggestions to have this sort of "loglog histogram" in a few
lines of code are more than welcome, of course.

Cheers,

Davide

There is numpy.histogram, which will give you the histogram without the plots.

But I have had little trouble using hist on log-log plots:

Try this (in ipython -pylab or with ">>> from pylab import *; import numpy"):

x = numpy.random.lognormal(size=1e4)
bins = logspace(-1.5, 1.5, 100)
hist(x, histtype='step', bins=bins)
xscale('log')
yscale('log')
show()

-Roban

···

On Wed, Nov 17, 2010 at 2:23 PM, Davide Fiocco <davide.fiocco@...287...> wrote:

Hi folks,

I want to bin sevaral arrays of data and superimpose them in a single plot.
The simplest approach is to fire several times

hist(data_i, N)

My problem is that I want to make a loglog plot (i.e. putting a
logscale on the X axis too, something that hist doesn't allow me to
do).

So what I've done so far is extracting the bin coordinates from
hist(data_i, N)[1], extract histogram values using hist(data_i, N)[0]
and then a loglog plot them one against each other.

The point is that I have to invoke at least once the command
hist(data_i, N) in order to do so, and this draws patches on my figure
which I don't want to appear on my final plot.

How do I delete the histogram bars? In other words, how to I delete an
entire histogram from my plot?

Other suggestions to have this sort of "loglog histogram" in a few
lines of code are more than welcome, of course.

Cheers,

Davide

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Roban Hultman Kramer | Zwicky Fellow | Institute for Astronomy
ETH Zürich (Swiss Federal Institute of Technology)