AlgebraOfGraphics.jl
AlgebraOfGraphics.jl copied to clipboard
Make the `color = dims(1)` correspond to the `mapping` for wide data
Problem description
I am making a line plot with wide data. The command is
p = data(df_collapsed) * mapping(:mean_age, [:N, :U, :B, :W], color = dims(1) => renamer(["N", "U", "B", "W"])) * visual(Lines)
See how I have to repeat ["N", "U", "B", "W"] twice? I should just have to write dims(1) and have it automatically take the name of the lines from the mapping.
Here is an MWE
julia> using AlgebraOfGraphics, GLMakie, DataFrames;
julia> df = DataFrame(x = 1:10, y1 = rand(10) .+ 1, y2 = rand(10) .+ 2);
julia> p = data(df) * mapping(:x, [:y1, :y2], color = dims(1)) * linear();
julia> draw(p)
Which gives
I would like the two lines on the graph to be labelled "y1" and "y2" rather than CartesianIndex as is the current behavior.