Skip to content

Instantly share code, notes, and snippets.

@pineapplehunter
Last active August 21, 2022 13:42
Show Gist options
  • Save pineapplehunter/bf75b8d67a1d6859dfabd8dc7d987c31 to your computer and use it in GitHub Desktop.
Save pineapplehunter/bf75b8d67a1d6859dfabd8dc7d987c31 to your computer and use it in GitHub Desktop.
Julia DSP.jl Filter plot like MATLAB zplane
using DSP
using RecipesBase
@recipe function plot(
f::FilterCoefficients;
xguide = "Real part",
yguide = "Imaginary part",
legend = true,
unitcolor = :auto,
zerocolor = :auto,
zeromarker = :o,
polecolor = :auto,
polemarker = :x,
)
f = ZeroPoleGain(f)
xguide := xguide
yguide := yguide
@series begin
seriestype := :path
label := ""
marker := :none
linestyle := :dash
seriescolor := unitcolor
cos, sin, 0, 2 * π
end
seriestype := :scatter
aspect_ratio := :equal
@series begin
label := "zero"
marker := zeromarker
markercolor := zerocolor
Complex.(f.z)
end
@series begin
label := "pole"
marker := polemarker
markercolor := polecolor
Complex.(f.p)
end
end
@tapyu
Copy link

tapyu commented Jul 20, 2022

That is wonderful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment