From ee23cb2185411b0e54262da5a7f996f6199a4624 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sat, 3 Jun 2017 01:14:25 +0200 Subject: [PATCH] grid --> false in spy recipe, removed info, added example --- src/examples.jl | 10 ++++++++++ src/recipes.jl | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/examples.jl b/src/examples.jl index 2fd6a0e9..60fa7fc5 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -318,6 +318,16 @@ PlotExample("Animation with subplots", end)] ), +PlotExample("Spy", + "For a matrix `mat` with unique nonzeros `spy(mat)` returns a colorless plot. If `mat` has various different nonzero values, a colorbar is added. The colorbar can be disabled with `legend = nothing`. As always, the marker shape and size can be changed with `spy(mat, markersize = 5, markershape = :diamond)`", + [:(begin + a = spdiagm((ones(200), ones(199), ones(199), ones(150), ones(150)),(0, 1, -1, 50, -50)) + n = 20 + b = [i > j ? i * j : 0 for i in 1:n, j in 1:n] + plot(spy(a), spy(b, markersize = 5, markershape = :diamond), title = ["Unique nonzeros" "Different nonzeros"], yguide = "Row", xguide = "Column") + end)] +), + ] # --------------------------------------------------------------------------------- diff --git a/src/recipes.jl b/src/recipes.jl index ec02911f..26f4105a 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -976,6 +976,9 @@ end @assert length(g.args) == 1 && typeof(g.args[1]) <: AbstractMatrix seriestype := :spy mat = g.args[1] + if length(unique(mat)) <= 2 + legend --> nothing + end n,m = size(mat) Plots.SliceIt, 1:m, 1:n, Surface(mat) end @@ -990,7 +993,6 @@ end markershape := :circle end if d[:markersize] == default(:markersize) - info("In the spy recipe the default markersize is 1. If you are viewing a small matrix, you may consider increasing it with the markersize attribute.") markersize := 1 end markerstrokewidth := 0 @@ -1000,6 +1002,7 @@ end y := rs z := nothing seriestype := :scatter + grid --> false () end