cycler icon indicating copy to clipboard operation
cycler copied to clipboard

Peusdo-infinite cycle

Open projetmbc opened this issue 9 years ago • 1 comments

It could be useful to have the possibility to define a pseudo-infinite cycle which gives some first colors and then use the last one defined in the cycle.

Why this could be useful ? When you have several curves, it could be better to just colorize some curves to highlight them whereas the others are less important but you still need to show them in gray for example.

Here is an example : see the rule 8.

projetmbc avatar Feb 16 '16 09:02 projetmbc

Interesting idea, but there are some tricky details to work out. For one thing, the composite operations currently rely on knowing the length of the Cyclers involved. I can see how to fake up+ to work with these trailing cyclers, but not *

A simple way to make this work only on the outer-most layer

def pcycle(itr):
    itr = iter(itr)
    last = next(itr)
    yield last
    try:
        while True:
            last = next(itr)
            yield last
    except StopIteration:
        while True:
            yield last

which is something that might already exist in itertools and friends.

As of 2 days ago, there is now a released version of cycler with concat which you could also use to fake up what you want (if you know how big your data is).

You could also do something like (again, works with 0.10)

sty_cy = itertools.chain(colorful_cycle, boring_cycle())

or

sty_cy = itertools.chain(colorful_cycle, itertools.repeat(final_sty_dict))

tacaswell avatar Feb 17 '16 13:02 tacaswell