How to plot different series from an array

Hello, I am using Atom on a Windows 10 and I have an array named final_output_array with three columns which looks like (but without column titles in Atom and blue added for ease of reading)

image

And I want to make it look like

image

I am not sure how to specify the series(species harvested) for the legend. I think it could be

labels = [final_array_output[1:5,1]] #here I think I need to specify [1,1] [6,1][11,1][16,1][21,1]
plot(final_array_output, xaxis=final_array_output[1:5,1, yaxis=final_array_output[1:5,3], label = labels)

Made up data for array

[1 1 12.34;2 1 45.32;3 1 23.4;4 1 56.43;5 1 90.2;1 2 45.3;2 2 76.2;3 2 72.3;4 2 72.6;5 2 30.2;1 3 53.2;2 3 42.3;3 3 94.1;4 3 23.0;5 3 19.2;1 4 20.3;2 4 30.2;3 4 98.2;4 4 53.9;5 4 83.7]

Hm… the data matrix looks complex, so I’m trying to divide up the problem. Assuming that your example data has 5 Species (1,…,5) and 4 Species harvested (1,…,4), I’m doing the following:

using Plots; pyplot();
data = [1 1 12.34;2 1 45.32;3 1 23.4;4 1 56.43;5 1 90.2;1 2 45.3;2 2 76.2;3 2 72.3;4 2 72.6;5 2 30.2;1 3 53.2;2 3 42.3;3 3 94.1;4 3 23.0;5 3 19.2;1 4 20.3;2 4 30.2;3 4 98.2;4 4 53.9;5 4 83.7];
fg = plot();
for sh in 1:4
    idx_sh = data[:,2] .== sh
    plot!(fg,data[idx_sh,1], data[idx_sh,3], lw=2,label="Species $(sh) harvested")
end
plot!(fg,xlabel="Species", "Biomass")

leads to:
image

A handful of comments.

  • By first doing fg = plot(), I create an empty plot pane and name it fg (my abbreviation for “fig”).
  • Next, statement plot!(fg,...) adds plot commands to the plot pane, which is nice in a loop.
  • In your indication of what the plot should look like, my interpretation is that you want the Species number (integer in range 1:5 in the given data) as abscissa (“x axis”) and Biomass (real number) as ordinate (“y axis”), with Species harvested (integer in range 1:4 in the given data) as parameter.
  • … so first I find the index of the rows that hold data for Species harvested no. 1, 2, 3, etc. (idx_sh = data[:,2] .== sh – or: the Index of Species harvested (idx_sh) where data in column 2 equals the Species harvested (sh) loop variable
  • … next, I plot the mapping data[idx_sh,1] vs. data[idx_sh,3], i.e., Species vs. Biomass in turn for parameter sh.
  • After the loop is finished, I add abscissa and ordinate labels (xlabel, ylabel). Note that the plot doesn’t show unless you do an explicitly plot(fg,...) command after the loop.

You can add niceties such as plot title, specify color of lines, etc., if you don’t like the default colors, etc.