From 6c6769ca98476a48f18a62c47580622c223a89f1 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Wed, 10 Feb 2016 13:09:22 -0500 Subject: [PATCH] handle vector of PlotText as annotations --- src/plot.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plot.jl b/src/plot.jl index a73191ef..c8c41605 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -186,12 +186,20 @@ updateDictWithMeta(d::Dict, plotargs::Dict, meta, isx::Bool) = nothing annotations(::@compat(Void)) = [] annotations{X,Y,V}(v::AVec{@compat(Tuple{X,Y,V})}) = v annotations{X,Y,V}(t::@compat(Tuple{X,Y,V})) = [t] +annotations(v::AVec{PlotText}) = v annotations(anns) = error("Expecting a tuple (or vector of tuples) for annotations: ", "(x, y, annotation)\n got: $(typeof(anns))") function _add_annotations(plt::Plot, d::Dict) anns = annotations(get(d, :annotation, nothing)) if !isempty(anns) + + # if we just have a list of PlotText objects, then create (x,y,text) tuples + if typeof(anns) <: AVec{PlotText} + x, y = plt[plt.n] + anns = Tuple{Float64,Float64,PlotText}[(x[i], y[i], t) for (i,t) in enumerate(anns)] + end + _add_annotations(plt, anns) end end