def _opacity_from_bin(bin, n_bins):
    """ Return opacity for bin."""
    if n_bins <= 0:
        return 0.35
    ratio = bin/float(n_bins)
    if ratio < 0.2:
        return 0.6
    elif ratio < 0.3:
        return 0.85
    elif ratio < 0.5:
        return 1.0
    return 1.0