# Reset color cycle with RecipesBase

**URL:** <https://discourse.julialang.org/t/reset-color-cycle-with-recipesbase/64706>\
**Category:** Visualization\
**Tags:** plots, recipe\
**Created:** [July 15, 2021, 6:01pm UTC](https://discourse.julialang.org/t/reset-color-cycle-with-recipesbase/64706 "2021-07-15T18:01:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![giancarloantonucci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giancarloantonucci/32/202551_2.png) [@giancarloantonucci](https://discourse.julialang.org/u/giancarloantonucci)\
**Post date:** [July 15, 2021, 6:01pm UTC](https://discourse.julialang.org/t/reset-color-cycle-with-recipesbase/64706/1 "2021-07-15T18:01:57Z")

</div>

Say I define a struct `Example` like:

```julia
struct Example
    fields
end
example = Example([rand(3), rand(3), rand(3)])

```

Using `RecipesBase`, I can define a plot recipe that allows me to plot each component of such a struct:

```julia
using RecipesBase
@recipe function f(example::Example)
    N = length(example.fields)
    for n in 1:N
        @series example.fields[n]
    end
end

```

When I run `plot(example)`, each component `example[n]` is plotted with a different colour, as expected:

```julia
using Plots
plot(example)

```

![example](https://global.discourse-cdn.com/julialang/original/3X/3/4/34446a7d4c22fe5a85498cb82209fb4341592e13.png)

How can I change the above recipe such that it resets the color cycle at every iteration of the for loop? The application I have in mind is for structs (of arrays) of more complex plottable objects.
