You’re starting out with a wide-format dataframe which is not the most convenient format for AlgebraOfGraphics. It does have some convenience built in for that case as well, but generally it’s a bit easier to start with long-format because then you don’t have to wrangle the multi-dimensional mappings.
Let me try to put it into high-level perspective: In AlgebraOfGraphics you use a tabular data source and specify columns you want to plot. These columns are split into groups by specifying categorical columns in mapping. Each group then becomes one “trace” or separate plot, maybe split across facets even if you use layout, row or col. But there’s another higher level of grouping and that’s the multidimensional or “wide” case. This means that you basically define a “tensor” of mappings and for each element in this tensor you do the whole pipeline of grouping by categorical columns etc. So here it’s just a one-dimensional tensor (the vector of y columns) but it can go to arbitrarily many dimensions in principle. The dimensions don’t matter much except for the dims mapping helper which is special as it makes a faux categorical variable along one (or more, but usually one) dimension of the mapping tensor. This is cool and all, but the zero-dimensional case (where all mappings are just symbols) or long-format is the simplest and should be what you start with.
So here are the examples you wanted in wide format, note the need for => renamer(ys) because the dimensions of the multidimensional input don’t automatically have names (maybe the could have them in simple cases but generally different mappings could contribute to the same dimensions). I factored out the ys variable to keep it less verbose.
xs = 0.0:10
m = hcat(xs, make_y(xs, 5))
ys = ["y$n" for n in 1:5]
nms = vcat("x", ys)
df = DataFrame(m, nms)
data(df) * mapping(:x, ys) * visual(Lines) |> draw
data(df) * mapping(:x, ys, color = dims(1) => renamer(ys)) * visual(Lines) |> draw
data(df) * mapping(:x, ys, color = dims(1) => renamer(ys)) * visual(Lines) |> draw(scales(Color = (; palette = :Set1_5)))
data(df) * mapping(:x, ys, linestyle = dims(1) => renamer(ys)) * visual(Lines) |> draw
data(df) * mapping(:x, ys, color = dims(1) => renamer(ys)) * visual(Scatter) |> draw
data(df) * mapping(:x, ys, marker = dims(1) => renamer(ys)) * visual(Scatter) |> draw
And here’s the same ones in long format. Most are simpler, only the first one needs the additional group mapping because there’s just one zigzagging line otherwise:
dfl = stack(df, ys)
rename!(dfl, :value => :y, :variable => :group)
data(dfl) * mapping(:x, :y, group = :group) * visual(Lines) |> draw
data(dfl) * mapping(:x, :y, color = :group) * visual(Lines) |> draw
data(dfl) * mapping(:x, :y, color = :group) * visual(Lines) |> draw(scales(Color = (; palette = :Set1_5)))
data(dfl) * mapping(:x, :y, linestyle = :group) * visual(Lines) |> draw
data(dfl) * mapping(:x, :y, color = :group) * visual(Scatter) |> draw
data(dfl) * mapping(:x, :y, marker = :group) * visual(Scatter) |> draw