In the typical histogram created with Numpy.histogram or matplotlib.pyplot.hist, the bins are of uniform width or the user specifies his/her own bin edges. There are lots of choices about optimal bin width -- say sqrt(sample size).
Sometimes, there are bins with zero objects in them -- e.g., at the extremes of the histogram. This can be a pain if one wants to look for a correlation -- e.g., if you want to check whether the number of objects in each bin increases as the quantity on the x-axis increases. (Imagine a histogram in which nearly every other bin has effectively 0 objects, or a histogram in which the first and last bins have effectively 0 objects -- both cases lead to poor visualization of the data and make it harder to see any underlying correlation.)
In such cases, it might be beneficial to impose a threshold on the binning such that each bin contains at least N objects. Of course, the bin widths will probably no longer be uniform.
Is there an easy way (i.e., a built-in function) to create such a "thresholded-histogram" in Python, using Numpy, Scipy, or matplotlib? Or at least to split up a monotonic array of numbers such that each sub-array contains at least N numbers?
Also, is such a binning algorithm considered to be optimal (in that the resulting histogram gives you a smoother visualization of where your data is), or sub-optimal (in that you are manipulating the binning to your advantage, rather than merely showing the data as-is)?