def loghistogram(data, base=2, ascii=True, title="Counts", summary=False):
    """
    bins is a dictionary with key: log(x, base), value: counts.
    """
    from jcvi.utils.cbook import percentage

    if summary:
        unique = len(data)
        total = sum(data)

        # Print out a distribution
        print("Unique: {0}".format(percentage(unique, total)), file=sys.stderr)

    bins = defaultdict(int)
    for d in data:
        logd = int(log(d, base))
        bins[logd] += 1

    x, y = [], []
    for size, number in sorted(bins.items()):
        lb, ub = base ** size, base ** (size + 1)
        x.append((lb, ub))
        y.append(number)

    asciiplot(x, y, title=title)
def loghistogram ( data , base = 2 , ascii = True , title = "Counts" , summary = False ) : from jcvi . utils . cbook import percentage if summary : unique = len ( data ) total = sum ( data ) print ( "Unique: {0}" . format ( percentage ( unique , total ) ) , file = sys . stderr ) bins = defaultdict ( int ) for d in data : logd = int ( log ( d , base ) ) bins [ logd ] += 1 x , y = [ ] , [ ] for size , number in sorted ( bins . items ( ) ) : lb , ub = base ** size , base ** ( size + 1 ) x . append ( ( lb , ub ) ) y . append ( number ) asciiplot ( x , y , title = title )
bins is a dictionary with key: log(x, base), value: counts.