Move the @userplot recipes
https://github.com/JuliaPlots/RecipesBase.jl/pull/16
This commit is contained in:
parent
554d7ab887
commit
67e5598d28
@ -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()
|
const _series_recipe_deps = Dict()
|
||||||
|
|
||||||
function series_recipe_dependencies(st::Symbol, deps::Symbol...)
|
function series_recipe_dependencies(st::Symbol, deps::Symbol...)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user