What if we have one type recipe for the x-axis and one for the y-axis?

If we define a type recipe for MyWrapper which is the independent variable (x) and one type recipe for MyOtherWrapper which is the dependent variable (y). It seems that the plot attributes defined in MyWrapper are preferred. Why is that?

struct MyWrapper
    v::Vector
end
struct MyOtherWrapper
    w::Vector
end

@recipe function f(::Type{MyWrapper}, mw::MyWrapper)
    seriestype --> :path
    markershape --> :circle
    markersize --> 2
    markerstrokewidth --> 2
    return mw.v
end
@recipe function f(::Type{MyOtherWrapper}, mow::MyOtherWrapper)
    seriestype --> :path
    markershape --> :star
    markersize --> 3
    markerstrokewidth --> 1
    return mow.w
end
julia> x = MyWrapper(cumsum(rand(10)));

julia> y = MyOtherWrapper(rand(10));

julia> plot(x, y)

See the example:

plot(MyWrapper(vals), MyOtherWrapper(times))

here.

Implemented here
where Volumes is x-axis, and Energies, etc., are y-axes.

1 Like