Member Avatar for tottletj

Hi, I'm currently trying to do something which I thought would be relatively straightforward, but it appears not.

Basically, I have a set of data that needs to be done logarithmically in a histogram, but appears the 'log=True' command in the pylab.hist() only refers to the y axis, rather than the logging the bins and x axis like i hoped. So, i know i can manually log the x axis (with pylab.semilogx()), but I'm tried finding out how to do log bins. However this seemed to not be possible, so I'm now trying to find out how to put my own desired bins into it. There should be an easy way to this.

For example, if I have the following code:

import pylab
a=[0.1,0.3,0.5,0.5,0.7,0.7,0.9]
pylab.figure()
pylab.hist(a,bins=4,range=(0,1))
pylab.show

it gives me a graph with a value of 1 between 0.0-0.25, 1 for 0.25-0.5, 4 for 0.5-0.75 and 1 for 0.75-1.0.
however, if I want to split just the dense bin up further, into 0.5-0.625 and 0.625-0.75 (which will give me a value of 2 in each), how can I make the histograph plot this?
How can i tell it my desired range of bins is from:
0.0-0.25
0.25-0.5
0.5-0.625
0.625-0.75
0.75-1.0?

thanks for your help

Recommended Answers

All 2 Replies

If pylab has not it, I remember that numpy has function for classifying values.

Member Avatar for tottletj

If pylab has not it, I remember that numpy has function for classifying values.

what is the numpy function? I can't find one. How would I then plot the histogram with numpy instead of pylab?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.