diff --git a/docs/qwt_examples.md b/docs/qwt_examples.md index 3904ecf2..42f30033 100644 --- a/docs/qwt_examples.md +++ b/docs/qwt_examples.md @@ -80,7 +80,7 @@ plot(Vector[randn(100),randn(100) * 100]; axis=[:l,:r],ylabel="LEFT",yrightlabel ### Vectors w/ pluralized args -Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`). +Plot multiple series with different numbers of points. Mix arguments that apply to all series (marker/markersize) with arguments unique to each series (colors). ```julia plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,c=[:red,:blue]) @@ -207,3 +207,15 @@ subplot!(randn(100,3)) ![](../img/qwt/qwt_example_18.png) +### Annotations + +Currently only text annotations are supported. Pass in a tuple or vector-of-tuples: (x,y,text). `annotate!(ann)` is shorthand for `plot!(; annotation=ann)` + +```julia +y = rand(10) +plot(y,ann=(3,y[3],"this is #3")) +annotate!([(5,y[5],"this is #5"),(9,y[10],"this is #10")]) +``` + +![](../img/qwt/qwt_example_20.png) + diff --git a/img/qwt/qwt_example_20.png b/img/qwt/qwt_example_20.png new file mode 100644 index 00000000..54d91ed6 Binary files /dev/null and b/img/qwt/qwt_example_20.png differ diff --git a/src/backends/qwt.jl b/src/backends/qwt.jl index cf6ea216..7b2212aa 100644 --- a/src/backends/qwt.jl +++ b/src/backends/qwt.jl @@ -9,7 +9,7 @@ qwt() = backend(:qwt) # supportedArgs(::QwtPackage) = setdiff(_allArgs, [:xlims, :ylims, :xticks, :yticks]) supportedArgs(::QwtPackage) = [ :annotation, - :args, + # :args, :axis, :background_color, :color, @@ -17,7 +17,7 @@ supportedArgs(::QwtPackage) = [ :foreground_color, :group, :heatmap_c, - :kwargs, + # :kwargs, :label, :layout, :legend, @@ -105,6 +105,21 @@ function updatePlotItems(plt::Plot{QwtPackage}, d::Dict) end +# ---------------------------------------------------------------- + + +function createQwtAnnotation(plt::Plot, x, y, val::AbstractString) + marker = Qwt.QWT.QwtPlotMarker() + marker[:setValue](x, y) + marker[:setLabel](Qwt.QWT.QwtText(val)) + marker[:attach](plt.o.widget) +end + +function addAnnotations{X,Y,V}(plt::Plot{QwtPackage}, anns::AVec{Tuple{X,Y,V}}) + for ann in anns + createQwtAnnotation(plt, ann...) + end +end # ----------------------------------------------------------------