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.
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