Skip to content

Commit 19b4674

Browse files
committed
add hooks for use with Winston.jl
1 parent a7fff46 commit 19b4674

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/KDE.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,15 @@ export kde, UnivariateKDE, BivariateKDE
1212
include("univariate.jl")
1313
include("bivariate.jl")
1414

15+
macro glue(pkg)
16+
path = joinpath(dirname(Base.source_path(nothing)),"glue",string(pkg,".jl"))
17+
init = symbol(string(pkg,"_init"))
18+
quote
19+
$(esc(init))() = include($path)
20+
isdefined(Main,$(QuoteNode(pkg))) && $(esc(init))()
21+
end
22+
end
23+
24+
@glue Winston
25+
1526
end # module

src/glue/Winston.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Winston
2+
import Winston: plot, imagesc
3+
4+
function plot(p::FramedPlot, k::UnivariateKDE, args...; kwargs...)
5+
plot(p, k.x, k.density, args...; kwargs...)
6+
end
7+
8+
function plot(k::UnivariateKDE, args...; kwargs...)
9+
plot(Winston.ghf(), k, args...; kwargs...)
10+
end
11+
12+
function imagesc(k::BivariateKDE, clims::Winston.Interval; kwargs...)
13+
imagesc(extrema(k.x), reverse(extrema(k.y)), k.density', clims; kwargs...)
14+
end
15+
function imagesc(k::BivariateKDE; kwargs...)
16+
imagesc(k, (0.0,maximum(k.density)); kwargs...)
17+
end

0 commit comments

Comments
 (0)