What are the advantages of using @recipe in Plots vs import RecipesBase.plot?

@recipe is described in its docstring as

This functionality is primarily geared to turning user types and settings into the data and
attributes that describe a Plots.jl visualization.

The example given to dispatch on type with its defaults is

 using RecipesBase
 type T end
 @recipe function plot{N<:Integer}(t::T, n::N = 1; customcolor = :green)
      markershape --> :auto, :require
      markercolor --> customcolor, :force
      xrotation --> 5
      zrotation --> 6, :quiet
      rand(10,n)
 end
 using Plots; gr()
 plot(T(), 5; customcolor = :black, shape=:c)

which seems it can be replicated without @recipe with:

using Plots
import RecipesBase.plot

struct T end
function plot(t::T,n::Integer=1,args...;customcolor = :green, kw...)
    x = rand(10,n)
    plot(x,args...;
         markercolor = customcolor,
         markershape = :auto,
         xrotation = 5, zrotation = 6,
         kw...)
end

plot(T(),5; customcolor = :black, shape = :c)

I wonder what would be the advantage(s) of using @recipe over import RecipesBase.plot to dispatch by type.

2 Likes