From 3a356ed1922159f93e2ac962fccd0da2e229715b Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 29 Apr 2024 16:21:02 +0200 Subject: [PATCH] fix ticks for categorical colorbar (#3762) --- src/makielayout/blocks/colorbar.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/makielayout/blocks/colorbar.jl b/src/makielayout/blocks/colorbar.jl index 9032a15a888..ac25b1374f2 100644 --- a/src/makielayout/blocks/colorbar.jl +++ b/src/makielayout/blocks/colorbar.jl @@ -167,7 +167,7 @@ function initialize_block!(cb::Colorbar) if mapping_type === Makie.banded error("Banded without a mapping is invalid. Please use colormap=cgrad(...; categorical=true)") elseif mapping_type === Makie.categorical - return convert(Vector{Float64},1:length(unique(values))) + return convert(Vector{Float64}, sort!(unique(values))) else return convert(Vector{Float64}, LinRange(limits..., n)) end @@ -212,7 +212,7 @@ function initialize_block!(cb::Colorbar) xmin, ymin = minimum(bb) xmax, ymax = maximum(bb) if mapping_type == Makie.categorical - colors = edges(colors) + colors = edges(1:length(colors)) end s_scaled = scale.(colors) mini, maxi = extrema(s_scaled)