Thanks, yes sorter indeed works. But it also changes the color mapping, which doesn’t play well with color palettes:
labels = ["x", "z", "y"]
d = (x='a':'c', y=[1, 2, 3], c=labels)
pal = ["x" => "red", "y" => "blue", "z" => "green"]
p = data(d) * mapping(:x, :y, color=:c => sorter(d.c)) * visual(BarPlot)
draw(p, palettes = (;color=pal))
This throws the following error:
ArgumentError: Key AlgebraOfGraphics.Sorted{String}(0x00000001, "x") not found and no default values are present
(::AlgebraOfGraphics.Cycler{String, String})(::AlgebraOfGraphics.Sorted{String})@scales.jl:20
iterate@generator.jl:47[inlined]
collect(::Base.Generator{Vector{AlgebraOfGraphics.Sorted{String}}, AlgebraOfGraphics.Cycler{String, String}})@array.jl:724
apply_palette(::Vector{Pair{String, String}}, ::Vector{AlgebraOfGraphics.Sorted{String}})@scales.jl:28
fitscale(::AlgebraOfGraphics.CategoricalScale{Vector{AlgebraOfGraphics.Sorted{String}}, Nothing, Vector{Pair{String, String}}})@scales.jl:57
map!(::typeof(AlgebraOfGraphics.fitscale), ::Dictionaries.Dictionary{Union{Int64, Symbol}, Any}, ::Dictionaries.Dictionary{Union{Int64, Symbol}, Any})@map.jl:57
var"#compute_axes_grid#116"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(:color,), Tuple{Vector{Pair{String, String}}}}, ::typeof(AlgebraOfGraphics.compute_axes_grid), ::AlgebraOfGraphics.Layer)@layers.jl:143
var"#compute_axes_grid#113"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(:color,), Tuple{Vector{Pair{String, String}}}}, ::typeof(AlgebraOfGraphics.compute_axes_grid), ::Makie.Figure, ::AlgebraOfGraphics.Layer)@layers.jl:117
#226@draw.jl:21[inlined]
update@draw.jl:10[inlined]
var"#plot!#225"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(:color,), Tuple{Vector{Pair{String, String}}}}, ::typeof(MakieCore.plot!), ::Makie.Figure, ::AlgebraOfGraphics.Layer)@draw.jl:21
(::AlgebraOfGraphics.var"#230#231"{NamedTuple{(), Tuple{}}, NamedTuple{(:color,), Tuple{Vector{Pair{String, String}}}}, NamedTuple{(), Tuple{}}, NamedTuple{(), Tuple{}}, NamedTuple{(), Tuple{}}, AlgebraOfGraphics.Layer})(::Makie.Figure)@draw.jl:46
update@draw.jl:10[inlined]
#draw#229@draw.jl:45[inlined]
top-level scope@Local: 6[inlined]