def duration_to_dt(duration):
    """
    Given a time duration, returns back the sampling rate of timeseries
    such that a maximum of 1000 points are plotted at a given time.

    This is used as a default if the user doesn't specify a dt explicitly.

    >>> duration_to_dt(900)
    1
    >>> duration_to_dt(11000)
    100

    """
    if duration <= 1000:
        dt = 1
    elif duration <= 10000:
        dt = 10
    elif duration <= 100000:
        dt = 100
    elif duration <= 1000000:
        dt = 1000
    elif duration <= 10000000:
        dt = 10000
    else:
        dt = 100000
    return dt
