# ControlSystems.jl: Custom labels in a plot of step response of a MIMO system

**URL:** <https://discourse.julialang.org/t/controlsystems-jl-custom-labels-in-a-plot-of-step-response-of-a-mimo-system/128821>\
**Category:** Modelling & Simulations\
**Tags:** controlsystems\
**Created:** [May 7, 2025, 8:38pm UTC](https://discourse.julialang.org/t/controlsystems-jl-custom-labels-in-a-plot-of-step-response-of-a-mimo-system/128821 "2025-05-07T20:38:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [May 7, 2025, 8:38pm UTC](https://discourse.julialang.org/t/controlsystems-jl-custom-labels-in-a-plot-of-step-response-of-a-mimo-system/128821/1 "2025-05-07T20:38:32Z")

</div>

I am struggling with setting my own labels correctly in a plot of a step response of a MIMO system.

Consider a generic MIMO LTI system with 2 inputs and 2 outputs, say:

```julia
using ControlSystems
using Plots
A = [-10 2; 3 -40]
B = [5 6; 7 8]
C = [9 10; 11 12]
G = ss(A, B, C, 0)

```

We compute the step response using the [step](https://juliacontrol.github.io/ControlSystems.jl/stable/lib/timefreqresponse/#Base.step-Tuple%7BAbstractStateSpace,%20AbstractVector%7D) function. When plotting it, I want to set my own `ylabel`s and my own `label`s. I do it by substituting a row matrix of strings.

```julia
step_response = step(G, 10.0)
plot(step_response, title="", xlabel="Time (s)", ylabel=["y₁" "y₂"], lw=2, label=["From u₁" "From u₂"], legend=:topright)

```

While this works for the `ylabel`, it does not for the `label`. What I get is

 ![step_response](https://global.discourse-cdn.com/julialang/original/3X/2/6/260070de02064a283f5158fa0bf487c5cf1ceb47.png)

Setting `label=["From u₁", "From u₂"]` does not help.

I can do it by using a named system as in

```julia
using RobustAndOptimalControl
G = named_ss(G, u = [:u₁, :u₂], y = [:y₁, :y₂])
step_response = step(G, 10.0)
plot(step_response, title="", xlabel="Time (s)", lw=2)

```

 ![step_response_2](https://global.discourse-cdn.com/julialang/original/3X/6/b/6b5c7edac2dfdbc596c25ad0ed67df7437f4af02.png)

But still, is it possible to do it without the named system, just by manually overwriting the labels in the plot?

---

<div class="post-metadata">

**Author:** ![dqeeq](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@dqeeq](https://discourse.julialang.org/u/dqeeq)\
**Post date:** [May 7, 2025, 9:48pm UTC](https://discourse.julialang.org/t/controlsystems-jl-custom-labels-in-a-plot-of-step-response-of-a-mimo-system/128821/2 "2025-05-07T21:48:10Z")

</div>

```julia
plot(step_response, title="", xlabel="Time (s)", ylabel=["y₁" "y₂"], lw=2, label=["From u₁" "From u₁" "From u₂" "From u₂"], legend=:bottomright)

```

---

<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:** [May 8, 2025, 4:56am UTC](https://discourse.julialang.org/t/controlsystems-jl-custom-labels-in-a-plot-of-step-response-of-a-mimo-system/128821/3 "2025-05-08T04:56:28Z")

</div>

The plot command expects the labels in the order the series are drawn in the plot recipe (which should ideally be an implementation detail only), and each series requires its own label. It’s unfortunately not trivial to intercept keywords or group multiple series together in a way that isn’t easily broken, so what I usually recommend when customizing plots turns out to be difficult is to split the plotting up into multiple plot commands.

This PR could potentially make it easier to customize the labels, in the limited case where you only want to change the name of the signals:

> <https://github.com/JuliaControl/ControlSystems.jl/pull/991>
>
> \`\`\`julia
> using Plots
> A = \[-10 2; 3 -40\]
> B = \[5 6; 7 8\]
> C = \[9 10; 11 12\]
> G …= ss(A, B, C, 0)
> step\_response = step(G, 10.0)
> plot(step\_response, title="", xlabel="Time (s)", lw=2, legend=:topright, input\_names=\["a", "b"\], output\_names=\["c", "d"\])
> \`\`\`
> !\[image\](https://github.com/user-attachments/assets/dffc7baf-cda0-48d5-9528-93fb59342886)
