Return the next color to be used in the given color cycle. 
    
    Warning: due to the structure of Python iterators I couldn't help but
    iterate over all the color cycle once. 

    If nonintrusive is True, then leave the color cycle in the same state as 
    before

def get_next_color(ax=None, nonintrusive=True):
    ''' Return the next color to be used in the given color cycle. 
    
    Warning: due to the structure of Python iterators I couldn't help but
    iterate over all the color cycle once. 

    If nonintrusive is True, then leave the color cycle in the same state as 
    before    
    '''

    if ax is None:
        ax = mpl.pyplot.gca()

    i = 1  # count number of elements
    cycle = ax._get_lines.prop_cycler  # color_cycle
    color = None
    a = next(cycle)     # a is already the next one.
    while(a != next(cycle)):
        i += 1
        color = a['color']

    if nonintrusive:
        # We want a-1 to show up on next call to next. So a-2 must be set now
        for j in range(i - 1):
            next(cycle)

    return color