Plot recipe that performs multiple plot calls

I am trying to define a recipe for a custom type. I have gotten a basic thing to work using the @userplot macro and following some examples, but I want to extend this to allow the recipe to do what would be multiple plot calls. Here is a simple MWE:

@userplot Custom3d
@recipe function f(p::Custom3d)
  x,y,z = p.args
  seriestype := :scatter
  x := vec(x
  y := y
  z := z
  ()
end

then doing custom3d(rand(3),rand(3),rand(3)) produces (for example):
q

What I want to do next is draw a shape on one of the “walls” of the box, i.e. a square with sides defined by the maximum value in x drawn on the +xz wall. With normal plot commands I could just do something like p = plot!([-maximum(x),-maximum(x),maximum(x),maximum(x)],[ylims(p)[2],ylims(p)[2],ylims(p)[2],ylims(p)[2]],[-maximum(x),maximum(x),maximum(x),-maximum(x)],fill=true), but I’m not sure how to accomplish the same thing within the @recipe macro?

I tried defining two series (placing the scatter commands inside one @series block and the shape commands inside a second) but that didn’t work. Any help appreciated!

I was missing putting a () at the bottom of each @series block. It works if you do that.

1 Like