Skip to content

Commit

Permalink
hz keyword in nyquistplot similar to in bodeplot (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen authored May 24, 2021
1 parent ae87d97 commit 490ba4d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ end

@userplot Nyquistplot
"""
fig = nyquistplot(sys; Ms_circles=Float64[], unit_circle=false, kwargs...)
fig = nyquistplot(sys; Ms_circles=Float64[], unit_circle=false, hz = false, kwargs...)
nyquistplot(LTISystem[sys1, sys2...]; Ms_circles=Float64[], unit_circle=false, kwargs...)
Create a Nyquist plot of the `LTISystem`(s). A frequency vector `w` can be
Expand All @@ -370,10 +370,12 @@ optionally provided.
- `unit_circle`: if the unit circle should be displayed
- `Ms_circles`: draw circles corresponding to given levels of sensitivity (circles around -1 with radii `1/Ms`). `Ms_circles` can be supplied as a number or a vector of numbers. A design staying outside such a circle has a phase margin of at least `2asin(1/(2Ms))` rad and a gain margin of at least `Ms/(Ms-1)`.
If `hz=true`, the hover information will be displayed in Hertz, the input frequency vector is still treated as rad/s.
`kwargs` is sent as argument to plot.
"""
nyquistplot
@recipe function nyquistplot(p::Nyquistplot; Ms_circles=Float64[], unit_circle=false)
@recipe function nyquistplot(p::Nyquistplot; Ms_circles=Float64[], unit_circle=false, hz=false)
systems, w = _processfreqplot(Val{:nyquist}(), p.args...)
ny, nu = size(systems[1])
nw = length(w)
Expand All @@ -395,10 +397,9 @@ nyquistplot
yguide --> "To: y($i)"
subplot --> s2i(i,j)
label --> "\$G_{$(si)}\$"
hover --> [Printf.@sprintf("ω = %.3f", w) for w in w]
hover --> [hz ? Printf.@sprintf("f = %.3f", w/2π) : Printf.@sprintf("ω = %.3f", w) for w in w]
(redata, imdata)
end

end

if si == length(systems)
@series begin # Mark the critical point
Expand Down

0 comments on commit 490ba4d

Please sign in to comment.