def keep_color(ax=None):
if ax is None:<EOL><INDENT>ax = mpl.pyplot.gca()<EOL><DEDENT>i = <NUM_LIT:1>  <EOL>cycle = ax._get_lines.prop_cycler<EOL>a = next(cycle)     <EOL>while(a != next(cycle)):<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT>for j in range(i - <NUM_LIT:2>):<EOL><INDENT>next(cycle)<EOL><DEDENT>
Keep the same color for the same graph. 
    Warning: due to the structure of Python iterators I couldn't help but
    iterate over all the cycle twice. One first time to get the number of elements
    in the cycle, one second time to stop just before the last. And this still 
    only works assuming your cycle doesn't contain the object twice

    Note: when setting color= it looks like the color cycle state is not called

    TODO: maybe implement my own cycle structure