AlgebraOfGraphics.jl icon indicating copy to clipboard operation
AlgebraOfGraphics.jl copied to clipboard

Make the `color = dims(1)` correspond to the `mapping` for wide data

Open pdeffebach opened this issue 2 years ago • 8 comments

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.

pdeffebach avatar Oct 17 '23 21:10 pdeffebach

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

image

I would like the two lines on the graph to be labelled "y1" and "y2" rather than CartesianIndex as is the current behavior.

pdeffebach avatar Nov 01 '23 18:11 pdeffebach