winston annotations
This commit is contained in:
parent
228ce768e0
commit
3334c4a87a
File diff suppressed because one or more lines are too long
30
examples/ticks_and_limits.ipynb
Normal file
30
examples/ticks_and_limits.ipynb
Normal 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
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user