Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AoG doesn't respect the levels of a categorical vector when transformation is applied #491

Open
pdeffebach opened this issue Mar 1, 2024 · 1 comment

Comments

@pdeffebach
Copy link

Here's an MWE

julia> using CategoricalArrays; 

julia> d = DataFrame(x = ["z", "a", "b"], v = [1, 2, 3]);

julia> d.x = categorical(d.x, ; levels = d.x);

julia> data(d) * mapping(:x, :v) * visual(BarPlot) |> draw

julia> # So far so good!

julia> d_labs = Dict("z" => "Z", "a" => "A", "b" => "B");

julia> data(d) * mapping(:x => (t -> d_labs[t]), :v) * visual(BarPlot) |> draw

It would be great is I could apply the transformation but then alzo have the "z" row go first.

@jkrumbiegel
Copy link
Member

jkrumbiegel commented Aug 22, 2024

Hm is this a common mechanic in other places where categorical arrays are used? In principle it seems sensible enough, if your target to transform is a categorical array, automatically convert the result to one as well, keeping the ordering intact. That would require a one-to-one mapping though, you can't go A => C, B => C because you lose a category, and you can't go A => rand(), A => rand() (not that I see a reason why you would).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants