# How do you label each timeseries on DifferentialEquations.jl plot?

**URL:** <https://discourse.julialang.org/t/how-do-you-label-each-timeseries-on-differentialequations-jl-plot/102456>\
**Category:** General Usage\
**Tags:** plots, differentialequation\
**Created:** [August 3, 2023, 6:38pm UTC](https://discourse.julialang.org/t/how-do-you-label-each-timeseries-on-differentialequations-jl-plot/102456 "2023-08-03T18:38:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [August 3, 2023, 6:38pm UTC](https://discourse.julialang.org/t/how-do-you-label-each-timeseries-on-differentialequations-jl-plot/102456/1 "2023-08-03T18:38:19Z")

</div>

I’ve got the solution to a differential equation, and i want to plot it, and I want each timeseries to have its own label in the legend:

```julia
p1 = plot(soln; xlim=(0,0.2), ylim=(0,100), title="Organisms vs Time", xlab="Time / Fly Lifetime",ylab="Organisms / Initial Number Of Adults",legend=:topleft,label=["eggs","larva","pupa","adult","food"])

```

This leads to the useless legend:

 ![Screenshot from 2023-08-03 11-37-23](https://global.discourse-cdn.com/julialang/original/3X/1/b/1b1115568bcdcf1e0db720fcd53c69023ca81dfb.png)

How do I associate names to the timeseries one at a time?

Note that the one example I could find actually just did the above! extremely ugly

[https://docs.sciml.ai/SciMLTutorialsOutput/html/introduction/05-formatting\_plots.html](https://docs.sciml.ai/SciMLTutorialsOutput/html/introduction/05-formatting_plots.html)

---

<div class="post-metadata">

**Author:** ![ANasc](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@ANasc](https://discourse.julialang.org/u/ANasc)\
**Post date:** [August 3, 2023, 7:37pm UTC](https://discourse.julialang.org/t/how-do-you-label-each-timeseries-on-differentialequations-jl-plot/102456/2 "2023-08-03T19:37:57Z")

</div>

Take out the commas between the labels, I think.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [August 3, 2023, 7:55pm UTC](https://discourse.julialang.org/t/how-do-you-label-each-timeseries-on-differentialequations-jl-plot/102456/3 "2023-08-03T19:55:10Z")

</div>

Wow, somehow I don’t think I’d have thought of that myself. It’s very odd to require a row matrix of names.

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [August 3, 2023, 8:02pm UTC](https://discourse.julialang.org/t/how-do-you-label-each-timeseries-on-differentialequations-jl-plot/102456/4 "2023-08-03T20:02:19Z")

</div>

Using a matrix rather than a vector is explained in the Plots.jl documentation below. (I personally don’t like it either.)

[Basics · Plots (juliaplots.org)](https://docs.juliaplots.org/stable/basics/)

> If the argument is a “matrix-type”, then [each column will map to a series](https://docs.juliaplots.org/stable/input_data/#columns-are-series), cycling through columns if there are fewer columns than series.

> A common error is to pass a Vector when you intend for each item to apply to only one series. Instead of an n-length Vector, pass a 1xn Matrix.

[Input Data · Plots (juliaplots.org)](https://docs.juliaplots.org/stable/input_data/#columns-are-series)

> This follows a consistent rule… vectors apply to a series, matrices apply to many series. This rule carries into keyword arguments.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [August 3, 2023, 8:24pm UTC](https://discourse.julialang.org/t/how-do-you-label-each-timeseries-on-differentialequations-jl-plot/102456/5 "2023-08-03T20:24:34Z")

</div>

I usually build up multi-line plots by doing my own `plot!` commands one per each, so I guess I managed to avoid needing to figure this out for the last 4 years or so.

It’s kind of amazing how comprehensive the julia Plots.jl infrastructure is.
