From 67e5598d28650064657c07edf0775e1aca14a2da Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 28 Apr 2017 22:43:23 -0700 Subject: [PATCH] Move the @userplot recipes https://github.com/JuliaPlots/RecipesBase.jl/pull/16 --- src/recipes.jl | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index 2da6ca60..02221cac 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -1,53 +1,4 @@ - - -""" -You can easily define your own plotting recipes with convenience methods: - -``` -@userplot type GroupHist - args -end - -@recipe function f(gh::GroupHist) - # set some attributes, add some series, using gh.args as input -end - -# now you can plot like: -grouphist(rand(1000,4)) -``` -""" -macro userplot(expr) - _userplot(expr) -end - -function _userplot(expr::Expr) - if expr.head != :type - errror("Must call userplot on a type/immutable expression. Got: $expr") - end - - typename = expr.args[2] - funcname = Symbol(lowercase(string(typename))) - funcname2 = Symbol(funcname, "!") - - # return a code block with the type definition and convenience plotting methods - esc(quote - $expr - export $funcname, $funcname2 - $funcname(args...; kw...) = plot($typename(args); kw...) - $funcname2(args...; kw...) = plot!($typename(args); kw...) - end) -end - -function _userplot(sym::Symbol) - _userplot(:(type $sym - args - end)) -end - - -# ---------------------------------------------------------------------------------- - const _series_recipe_deps = Dict() function series_recipe_dependencies(st::Symbol, deps::Symbol...)