# How to give names to the curves in 1D graph of 2D array?

**URL:** https://discourse.julialang.org/t/how-to-give-names-to-the-curves-in-1d-graph-of-2d-array/89182
**Category:** Visualization
**Created:** [October 24, 2022, 6:25am UTC](https://discourse.julialang.org/t/how-to-give-names-to-the-curves-in-1d-graph-of-2d-array/89182 "2022-10-24T06:25:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)
#### Post date: [October 24, 2022, 6:25am UTC](https://discourse.julialang.org/t/how-to-give-names-to-the-curves-in-1d-graph-of-2d-array/89182/1 "2022-10-24T06:25:15Z")

</div>

In my M x N array, the columns represent y values and so `plot(arr)` will produce N curves, which is what I need. But my question is, how can one give a name to each curve?

My first intuition was to give a vector of the names to the `label` attribute of `plot`. See the self-contained example below. But it gives the Stringified version of the vector to each curve.

My second intuition was: because each column of the 2D array represents a curve, the names of the curves should be a row vector . . . This leads to error.

A workaround I’ve found so far is to add curves one by one to the plot in a loop using `plot!()`, specifying the name of the curve each time.

```julia
using Plots
arr = hcat([1,2,4], [-1,-2,-4])
xaxis = 100:100:300
nams = ["positive", "negative"]
plot(xaxis, arr; label=nams)
plot(xaxis, arr; label=nams') # row vector of nams

```

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [October 24, 2022, 11:25am UTC](https://discourse.julialang.org/t/how-to-give-names-to-the-curves-in-1d-graph-of-2d-array/89182/2 "2022-10-24T11:25:33Z")

</div>

Since you’re already a bit familiar with it, DimensionalData.jl should do this for you pretty easily:

```julia
using Plots
arr = hcat([1,2,4], [-1,-2,-4])
da = DimArray(arr, (X(100:100:300), Y(["positive", "negative"])))
plot(da)

```

The trick is to use `permutedims` rather than `'`. Adjoint is annoyingly recursive so wont work on strings.

```julia
plot(xaxis, arr; label=permutedims(nams))

```
