Say I define a struct Example
like:
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:
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:
using Plots
plot(example)
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.