winston annotations

This commit is contained in:
Thomas Breloff 2015-09-28 12:52:44 -04:00
parent 228ce768e0
commit 3334c4a87a
4 changed files with 65 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,30 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"using Plots; gadfly!()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.4.0-rc1",
"language": "julia",
"name": "julia-0.4"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.4.0"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

View File

@ -8,7 +8,7 @@ gadfly!() = plotter!(:gadfly)
supportedArgs(::GadflyPackage) = setdiff(_allArgs, [:heatmap_c, :pos, :screen, :yrightlabel])
supportedAxes(::GadflyPackage) = setdiff(_allAxes, [:right])
supportedAxes(::GadflyPackage) = [:auto, :left]
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :ohlc]
supportedStyles(::GadflyPackage) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
supportedMarkers(::GadflyPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon, :octagon]
@ -227,14 +227,17 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
nothing
end
function replaceType(vec, val)
filter!(x -> !isa(x, typeof(val)), vec)
push!(vec, val)
end
function addTicksGuide(gplt, ticks, isx::Bool)
ticks == :auto && return
ttype = ticksType(ticks)
if ttype == :ticks
gtype = isx ? Gadfly.Guide.xticks : Gadfly.Guide.yticks
filter!(x -> !isa(x, gtype), gplt.guides)
push!(gplt.guides, gtype(ticks = sort(collect(ticks))))
replaceType(gplt.guides, gtype(ticks = collect(ticks)))
else
error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
end

View File

@ -37,6 +37,11 @@ supportedStyles(::WinstonPackage) = intersect(_allStyles, collect(keys(winston_l
supportedMarkers(::WinstonPackage) = intersect(_allMarkers, collect(keys(winston_marker)))
subplotSupported(::WinstonPackage) = false
function preparePlotUpdate(plt::Plot{WinstonPackage})
Winston.ghf(plt.o)
end
# ---------------------------------------------------------------------------
@ -183,13 +188,15 @@ end
# -------------------------------
# function savepng(::WinstonPackage, plt::PlottingObject, fn::AbstractString; kw...)
# f = open(fn, "w")
# window, canvas, wplt = getWinstonItems(plt)
# addWinstonLegend(plt, wplt)
# writemime(f, "image/png", wplt)
# close(f)
# end
function createWinstonAnnotationObject(plt::Plot{WinstonPackage}, x, y, val::AbstractString)
Winston.text(x, y, val)
end
function addAnnotations{X,Y,V}(plt::Plot{WinstonPackage}, anns::AVec{Tuple{X,Y,V}})
for ann in anns
createWinstonAnnotationObject(plt, ann...)
end
end
# -------------------------------
@ -201,7 +208,9 @@ end
# ----------------------------------------------------------------
function addWinstonLegend(plt::Plot, wplt)
if plt.initargs[:legend]
Winston.legend(wplt, [sd[:label] for sd in plt.seriesargs])
end
end
function Base.writemime(io::IO, ::MIME"image/png", plt::PlottingObject{WinstonPackage})