Skip to content

Commit

Permalink
allow viz poles zero to change legend position
Browse files Browse the repository at this point in the history
  • Loading branch information
cory simon authored and cory simon committed Jun 1, 2024
1 parent 9be1b6f commit 7cefaea
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/viz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,20 @@ plot the zeros and poles of the transfer function `g` in the complex plane.
returns a `CairoMakie.jl` `Figure` object for further modification.
"""
function viz_poles_and_zeros(tf::TransferFunction; savename::Union{Nothing, String}=nothing, title::String="poles and zeros")
function viz_poles_and_zeros(
tf::TransferFunction;
savename::Union{Nothing, String}=nothing,
title::String="poles and zeros",
legend_position::Symbol=:rc
)
z, p, k = zeros_poles_gain(tf)

fig = Figure()
ax = Axis(fig[1, 1], xlabel="Re", ylabel="Im", title=title)
draw_axes(ax)
scatter!(real.(z), imag.(z), marker=:circle, label="zeros", markersize=15)
scatter!(real.(p), imag.(p), marker=:x, label="poles", markersize=15)
axislegend()
axislegend(position=legend_position)
if ! isnothing(savename)
save(savename, fig, px_per_unit=1)
end
Expand Down

0 comments on commit 7cefaea

Please sign in to comment.