# Is it possible to plot gain margin and phase margin on the bode diagram?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-plot-gain-margin-and-phase-margin-on-the-bode-diagram/89876>\
**Category:** Modelling & Simulations\
**Tags:** controlsystems\
**Created:** [November 7, 2022, 12:55pm UTC](https://discourse.julialang.org/t/is-it-possible-to-plot-gain-margin-and-phase-margin-on-the-bode-diagram/89876 "2022-11-07T12:55:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucasmsoares96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucasmsoares96/32/38743_2.png) [@lucasmsoares96](https://discourse.julialang.org/u/lucasmsoares96)\
**Post date:** [November 7, 2022, 12:55pm UTC](https://discourse.julialang.org/t/is-it-possible-to-plot-gain-margin-and-phase-margin-on-the-bode-diagram/89876/1 "2022-11-07T12:55:04Z")

</div>

I didn’t find anything about this in the documentation.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [November 7, 2022, 1:19pm UTC](https://discourse.julialang.org/t/is-it-possible-to-plot-gain-margin-and-phase-margin-on-the-bode-diagram/89876/2 "2022-11-07T13:19:56Z")

</div>

Try the function [`marginplot`](https://juliacontrol.github.io/ControlSystems.jl/latest/lib/plotting/#Margin) or just `margin` in case you want to obtain the margins as variables. The `marginplot` function is currently struggling slightly with MIMO systems and some systems with multiple margins, but it should work fine for simple systems.

---

<div class="post-metadata">

**Author:** ![lucasmsoares96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucasmsoares96/32/38743_2.png) [@lucasmsoares96](https://discourse.julialang.org/u/lucasmsoares96)\
**Post date:** [November 7, 2022, 10:21pm UTC](https://discourse.julialang.org/t/is-it-possible-to-plot-gain-margin-and-phase-margin-on-the-bode-diagram/89876/3 "2022-11-07T22:21:58Z")

</div>

Perfect. Thank you!

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [January 10, 2023, 1:20pm UTC](https://discourse.julialang.org/t/is-it-possible-to-plot-gain-margin-and-phase-margin-on-the-bode-diagram/89876/4 "2023-01-10T13:20:08Z")

</div>

Another function you might find interesting is [diskmargin](https://juliacontrol.github.io/RobustAndOptimalControl.jl/dev/#Diskmargin-example), this version of the gain and phase margins makes more sense for MIMO systems.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 10, 2023, 2:44pm UTC](https://discourse.julialang.org/t/is-it-possible-to-plot-gain-margin-and-phase-margin-on-the-bode-diagram/89876/5 "2023-01-10T14:44:46Z")

</div>

Thanks! But the link [https://juliacontrol.github.io/ControlSystems.jl/latest/lib/plotting/#Margin](https://juliacontrol.github.io/ControlSystems.jl/latest/lib/plotting/#Margin) is not working …

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [January 10, 2023, 3:12pm UTC](https://discourse.julialang.org/t/is-it-possible-to-plot-gain-margin-and-phase-margin-on-the-bode-diagram/89876/6 "2023-01-10T15:12:39Z")

</div>

> [@ufechner7](#):
>
> [https://juliacontrol.github.io/ControlSystems.jl/latest/lib/plotting/#Margin](https://juliacontrol.github.io/ControlSystems.jl/latest/lib/plotting/#Margin)

Try [Plotting · ControlSystems.jl](https://juliacontrol.github.io/ControlSystems.jl/stable/lib/plotting/#Margin)

all doc links that included `latest` have recently changed to `stable` for some reason.
