From 3d3ec2a1940356fe10e521b26e91c63a31169536 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 2 Jun 2017 17:18:01 +0200 Subject: [PATCH 1/4] add info about default markersize in spy recipe --- src/recipes.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/recipes.jl b/src/recipes.jl index 9f647f73..ec02911f 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -990,6 +990,7 @@ 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 From ee23cb2185411b0e54262da5a7f996f6199a4624 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sat, 3 Jun 2017 01:14:25 +0200 Subject: [PATCH 2/4] 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 From 1a07c39fad7070351aae9f00fd09b2604b546d78 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sat, 3 Jun 2017 13:27:38 +0200 Subject: [PATCH 3/4] changed spy plot example --- src/examples.jl | 9 ++++----- src/recipes.jl | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/examples.jl b/src/examples.jl index 60fa7fc5..05980152 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -319,12 +319,11 @@ PlotExample("Animation with subplots", ), 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)`", + "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 = 3, markershape = :star)`", [:(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") + a = spdiagm((ones(50), ones(49), ones(49), ones(40), ones(40)),(0, 1, -1, 10, -10)) + b = spdiagm((1:50, 1:49, 1:49, 1:40, 1:40),(0, 1, -1, 10, -10)) + plot(spy(a, markershape = :star), spy(b), markersize = 3, title = ["Unique nonzeros" "Different nonzeros"]) end)] ), diff --git a/src/recipes.jl b/src/recipes.jl index 26f4105a..e8ea3096 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -976,7 +976,7 @@ end @assert length(g.args) == 1 && typeof(g.args[1]) <: AbstractMatrix seriestype := :spy mat = g.args[1] - if length(unique(mat)) <= 2 + if length(unique(mat[mat .!= 0])) < 2 legend --> nothing end n,m = size(mat) From 18d29a0c7c2fc2ce81a2298cf46fb63f24181c25 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Tue, 6 Jun 2017 22:51:34 +0200 Subject: [PATCH 4/4] changed markershape to :dtriangle in spy example --- src/examples.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples.jl b/src/examples.jl index 05980152..81fd9872 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -323,7 +323,7 @@ PlotExample("Spy", [:(begin a = spdiagm((ones(50), ones(49), ones(49), ones(40), ones(40)),(0, 1, -1, 10, -10)) b = spdiagm((1:50, 1:49, 1:49, 1:40, 1:40),(0, 1, -1, 10, -10)) - plot(spy(a, markershape = :star), spy(b), markersize = 3, title = ["Unique nonzeros" "Different nonzeros"]) + plot(spy(a, markershape = :dtriangle), spy(b), markersize = 3, title = ["Unique nonzeros" "Different nonzeros"]) end)] ),