I’m trying to do something seemingly simple with RecipesBase thats turning out to be a bit of a headache. Is there a pragmatic way to make a function that returns a call from an @recipe plot function?
Here is a toy prompt:
using RecipesBase using Plots struct PlotIt fn end (PI::PlotIt)(x) = PI.fn(x) @recipe function piplot( Shape::PlotIt, x ) x := x y := Shape.(x) seriestype := :path () end struct PlotOpposite fn::PlotIt end (PO::PlotOpposite)(x) = -PO.fn(x)
So what I want to do is something like the following:
@recipe function plotopp( PO::PlotOpposite, x ) return piplot(PlotIt( y -> -1 * PO.fn.fn(y) ), x) #Return the result of function call to piplot end
I know there are ways around this but I find this kind of pattern to be interesting. Figured I’d learn something making a post like this.
x = 0.0:0.1:(2pi) PI = PlotIt( sin ) Plots.plot( PI, x ) PO = PlotOpposite( PI) Plots.plot( PO.( x ) )#Desired outcome Plots.plot( PO, x ) #Broken