Odd behaviour of custom labels in Plot recipes

I’d probably write this as

using Plots

struct MyData
    times
    data
end

@recipe function f(mydata::MyData)
    @series begin
        label := "Constant"
        mydata.times, first(mydata.data)
    end
    for (d, l) in zip(mydata.data[2],["Straight" "Small Random" "Big Random"])
        @series begin
            label := l
            mydata.times, d
        end
    end
end
times = 1:10
vec = fill(2, 10)
vecofvec = [1:10, rand(10), 10*rand(10)]
mydata = MyData(times, [vec, vecofvec])
plot(mydata)
1 Like