import math


def step_size(domain, count=7, splits=(5, 3, 2, 1), base=10):
    """
    Calculates visually nice step size for given range.
    
    Args:
        domain: int or float
            Absolute value of current range.
        
        count: int
            Expected number of ticks.
        
        splits: (float,)
            Allowed splits.
        
        base: int
            Log base.
    
    Returns:
        float
            Step size.
    """
    
    ideal = math.fabs(domain) / float(max(1, count))
    log = math.log(ideal, base)
    power = math.floor(log)
    fraction = log - power
    error = float('inf')  # fraction
    
    factor = 1.
    for split in splits:
        e = math.fabs(fraction - math.log(split, base))
        if e < error:
            factor = split
            error = e
    
    step = factor * math.pow(base, power)
    
    return step