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

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

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.

plot(xaxis, arr; label=permutedims(nams))
1 Like