# Plots (plotly) multiple series or line labels in legend

**URL:** <https://discourse.julialang.org/t/plots-plotly-multiple-series-or-line-labels-in-legend/13001>\
**Category:** Visualization\
**Created:** [August 7, 2018, 5:45pm UTC](https://discourse.julialang.org/t/plots-plotly-multiple-series-or-line-labels-in-legend/13001 "2018-08-07T17:45:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [August 7, 2018, 5:45pm UTC](https://discourse.julialang.org/t/plots-plotly-multiple-series-or-line-labels-in-legend/13001/1 "2018-08-07T17:45:06Z")

</div>

how does one label two lines?

```julia
using Plots; pyplot()
plot(Plots.fakedata(50,2), w=3, labels=["a", "b"])

```

the blue line is not labeled “a” and the red line is not labeled “b” .

PS: [Overview · Plots](http://docs.juliaplots.org/latest/attributes/) writes “if label is empty”…what is empty?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [August 7, 2018, 6:55pm UTC](https://discourse.julialang.org/t/plots-plotly-multiple-series-or-line-labels-in-legend/13001/2 "2018-08-07T18:55:34Z")

</div>

This is the #1 most asked question on Plots. The answer is that columns are series - so you should use a row matrix. `label = ["a" "b"]`.  
There’s an open issue to change the behaviour to accept a Vector.

---

<div class="post-metadata">

**Author:** ![drbergman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drbergman/32/202226_2.png) [@drbergman](https://discourse.julialang.org/u/drbergman)\
**Post date:** [April 26, 2024, 1:18pm UTC](https://discourse.julialang.org/t/plots-plotly-multiple-series-or-line-labels-in-legend/13001/3 "2024-04-26T13:18:38Z")

</div>

For anyone else landing here 5+ years later, it seems Plots.jl has settled on **not** letting you pass in a Vector of labels. It must be a row vector as shown above.

**Warning** : What follows is guidance from a julia novice. If you have `labels=["a","b"]` of type `Vector{String}`, then I think the cleanest way to pass it in all at once is

```julia
t = 1:100
y = rand(Float64, (100,3))
labels = ["a","b","c"]
plot(t, y, labels = hcat(labels...))

```

Probably the best method overall is to call `plot` for each series and set that individual label like this:

```julia
t = 1:100
y = rand(Float64, (100,3))
labels = ["a","b","c"]
pl = plot()
for i in axes(y, 2)
    plot!(pl,t,y[:,i], label=labels[i])
end
display(pl)

```

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [April 26, 2024, 3:24pm UTC](https://discourse.julialang.org/t/plots-plotly-multiple-series-or-line-labels-in-legend/13001/4 "2024-04-26T15:24:04Z")

</div>

> [@drbergman](#):
>
> I think the cleanest way to pass it in all at once is

I usually do

```julia
labels = ["a","b","c"]
plot(t, y, labels = permutedims(labels))
```
