# Set ylims in marginplot

**URL:** https://discourse.julialang.org/t/set-ylims-in-marginplot/131469
**Category:** General Usage
**Tags:** plotting, controlsystems
**Created:** [August 8, 2025, 9:12am UTC](https://discourse.julialang.org/t/set-ylims-in-marginplot/131469 "2025-08-08T09:12:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![maltee1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maltee1/32/204977_2.png) [@maltee1](https://discourse.julialang.org/u/maltee1)
#### Post date: [August 8, 2025, 9:12am UTC](https://discourse.julialang.org/t/set-ylims-in-marginplot/131469/1 "2025-08-08T09:12:08Z")

</div>

How do I set y limits for marginplot (or bodeplot)? `ylims` just sets the limits for both the margin and the phase the same, which is rarely helpful. There is `ylimsphase`, which only works for bodeplot, not marginplot, and doesn’t seem to do anything (it’s commented out in the code).  
Is there a way to adjust the limits after plotting?

Minimal working example (has infinite margin, so marginplot is no different from bodeplot, but that’s not what I have trouble with anyway):

```julia-auto
using Plots
using ControlSystemsBase
s=tf('s')
marginplot(1/(s+10))
title!("")

```

---

<div class="post-metadata">

### Author: ![maltee1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maltee1/32/204977_2.png) [@maltee1](https://discourse.julialang.org/u/maltee1)
#### Post date: [August 8, 2025, 9:26am UTC](https://discourse.julialang.org/t/set-ylims-in-marginplot/131469/2 "2025-08-08T09:26:45Z")

</div>

nevermind, I found it, e.g.:

```julia-auto
using Plots
using ControlSystemsBase
s=tf('s')
p1=marginplot(1/(s+10))
ylims!(p1.subplots[2], (-200, -150))
title!("")

```

---

<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: [August 8, 2025, 9:28am UTC](https://discourse.julialang.org/t/set-ylims-in-marginplot/131469/3 "2025-08-08T09:28:47Z")

</div>

You can also pass a `1 x 2` row of tuples

```julia-auto
marginplot(1/(s+10), ylims=[(1e-2, 1) (-120, 0)])

```

Using two columns is Plots.jl syntax to control the two distinct series (magnitude is the first, phase the second), this mirrors the fact that one can plot two series by passing an `N x 2` matrix with two columns.

---

<div class="post-metadata">

### Author: ![maltee1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maltee1/32/204977_2.png) [@maltee1](https://discourse.julialang.org/u/maltee1)
#### Post date: [August 8, 2025, 9:31am UTC](https://discourse.julialang.org/t/set-ylims-in-marginplot/131469/4 "2025-08-08T09:31:39Z")

</div>

that’s better, thanks!
