def select_lim_and_tick(lim_c, tick_c, n_tick_c):
    """
    Select limits and tick mark spacings that give a pleasing number of tick 
    marks
    
    Parameters
    ----------
    lim_c : Nx2 list or numpy array
        A list of axis limit candidates
    tick_c : Nx1 list or numpy array
        A list of tick mark spacing candidates.
    n_tick_c : Nx1 list or numpy array
        A list of number of tick marks candidates
        
    Returns
    -------
    lim : 1x2 list or numpy array
        Optimum axis limits
    tick : float
        Optimum tick mark spacing
    n_tick_c : float or int
        Optimum number of tick marks
    """
    ideal_ndx = ((n_tick_c >= 4.0) & (n_tick_c <= 6.0)).nonzero()[0]
    if len(ideal_ndx) > 0:
        lim = lim_c[(ideal_ndx[-1]), :]
        tick = tick_c[ideal_ndx[-1]]
        n_tick = n_tick_c[ideal_ndx[-1]]
    else:
        good_ndx = ((n_tick_c >= 3.0) & (n_tick_c <= 7.0)).nonzero()[0]
        if len(good_ndx) > 0:
            lim = lim_c[(good_ndx[-1]), :]
            tick = tick_c[good_ndx[-1]]
            n_tick = n_tick_c[good_ndx[-1]]
        else:
            lim = lim_c[(0), :]
            tick = tick_c[0]
            n_tick = n_tick_c[0]
    return lim, tick, n_tick
