From 5e8c88d657f76e3609bca588706e0669c5a963d7 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Sun, 9 Oct 2016 00:52:53 -0400 Subject: [PATCH] spy recipes --- src/recipes.jl | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/recipes.jl b/src/recipes.jl index ffca23fc..78db2d7d 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -742,6 +742,43 @@ end # kw...) # end +# Only allow matrices through, and make it seriestype :spy so the backend can +# optionally handle it natively. + +@userplot Spy + +@recipe function f(g::Spy) + @assert length(g.args) == 1 && typeof(g.args[1]) <: AbstractMatrix + seriestype := :spy + mat = g.args[1] + n,m = size(mat) + Plots.SliceIt, 1:m, 1:n, Surface(mat) +end + +@recipe function f(::Type{Val{:spy}}, x,y,z) + yflip := true + aspect_ratio := 1 + rs, cs, zs = findnz(z.surf) + xlim := extrema(cs) + ylim := extrema(rs) + if d[:markershape] == :none + markershape := :circle + end + if d[:markersize] == default(:markersize) + markersize := 1 + end + markerstrokewidth := 0 + marker_z := zs + label := "" + x := cs + y := rs + z := nothing + seriestype := :scatter + () +end + +# ------------------------------------------------- + "Adds a+bx... straight line over the current plot" function abline!(plt::Plot, a, b; kw...) plot!(plt, [extrema(plt)...], x -> b + a*x; kw...)