Plots.findnz for sparse and non-sparse matrices
This commit is contained in:
parent
0ee1d867c9
commit
43f31cbc98
@ -10,7 +10,7 @@ using Reexport
|
|||||||
|
|
||||||
import GeometryTypes
|
import GeometryTypes
|
||||||
using Dates, Printf, Statistics, Base64, LinearAlgebra, Random
|
using Dates, Printf, Statistics, Base64, LinearAlgebra, Random
|
||||||
import SparseArrays: findnz
|
import SparseArrays: AbstractSparseMatrix, findnz
|
||||||
|
|
||||||
using FFMPEG
|
using FFMPEG
|
||||||
|
|
||||||
|
|||||||
@ -1028,7 +1028,7 @@ end
|
|||||||
|
|
||||||
function error_style!(plotattributes::AKW)
|
function error_style!(plotattributes::AKW)
|
||||||
plotattributes[:seriestype] = :path
|
plotattributes[:seriestype] = :path
|
||||||
plotattributes[:markercolor] = plotattributes[:markerstrokecolor]
|
plotattributes[:markercolor] = plotattributes[:markerstrokecolor]
|
||||||
plotattributes[:linewidth] = plotattributes[:markerstrokewidth]
|
plotattributes[:linewidth] = plotattributes[:markerstrokewidth]
|
||||||
plotattributes[:label] = ""
|
plotattributes[:label] = ""
|
||||||
end
|
end
|
||||||
@ -1415,7 +1415,7 @@ end
|
|||||||
@recipe function f(::Type{Val{:spy}}, x, y, z)
|
@recipe function f(::Type{Val{:spy}}, x, y, z)
|
||||||
yflip := true
|
yflip := true
|
||||||
aspect_ratio := 1
|
aspect_ratio := 1
|
||||||
rs, cs, zs = findnz(z.surf)
|
rs, cs, zs = Plots.findnz(z.surf)
|
||||||
xlims := ignorenan_extrema(cs)
|
xlims := ignorenan_extrema(cs)
|
||||||
ylims := ignorenan_extrema(rs)
|
ylims := ignorenan_extrema(rs)
|
||||||
if plotattributes[:markershape] == :none
|
if plotattributes[:markershape] == :none
|
||||||
@ -1435,6 +1435,18 @@ end
|
|||||||
()
|
()
|
||||||
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"
|
"Adds ax+b... straight line over the current plot, without changing the axis limits"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user