Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peusdo-infinite cycle #30

Open
projetmbc opened this issue Feb 16, 2016 · 1 comment
Open

Peusdo-infinite cycle #30

projetmbc opened this issue Feb 16, 2016 · 1 comment
Milestone

Comments

@projetmbc
Copy link

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.

@tacaswell
Copy link
Member

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 tacaswell modified the milestones: v1.1, v1.0 Jun 4, 2016
tacaswell added a commit to tacaswell/cycler that referenced this issue Jun 5, 2016
Add a generator function to add an infinite 'tail' onto a cycler.

Closes matplotlib#30
tacaswell added a commit to tacaswell/cycler that referenced this issue Jun 5, 2016
Add a generator function to add an infinite 'tail' onto a cycler.

Closes matplotlib#30
@QuLogic QuLogic modified the milestones: v0.10, v1.0 Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants