diff --git a/src/Plots.jl b/src/Plots.jl index 7c8b0d1e..18ea9120 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -10,7 +10,7 @@ using Reexport import GeometryTypes using Dates, Printf, Statistics, Base64, LinearAlgebra, Random -import SparseArrays: findnz +import SparseArrays: AbstractSparseMatrix, findnz using FFMPEG diff --git a/src/recipes.jl b/src/recipes.jl index e7bdb7ac..abd6748a 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -1028,7 +1028,7 @@ end function error_style!(plotattributes::AKW) plotattributes[:seriestype] = :path - plotattributes[:markercolor] = plotattributes[:markerstrokecolor] + plotattributes[:markercolor] = plotattributes[:markerstrokecolor] plotattributes[:linewidth] = plotattributes[:markerstrokewidth] plotattributes[:label] = "" end @@ -1415,7 +1415,7 @@ end @recipe function f(::Type{Val{:spy}}, x, y, z) yflip := true aspect_ratio := 1 - rs, cs, zs = findnz(z.surf) + rs, cs, zs = Plots.findnz(z.surf) xlims := ignorenan_extrema(cs) ylims := ignorenan_extrema(rs) if plotattributes[:markershape] == :none @@ -1435,6 +1435,18 @@ end () end + +Plots.findnz(A::AbstractSparseMatrix) = findnz(A) + +# fallback function for finding non-zero elements of non-sparse matrices +function Plots.findnz(A::AbstractMatrix) + keysnz = findall(!iszero, A) + rs = [k[1] for k in keysnz] + cs = [k[2] for k in keysnz] + zs = A[keysnz] + rs, cs, zs +end + # ------------------------------------------------- "Adds ax+b... straight line over the current plot, without changing the axis limits"