Proper order when cycling through colormap

Using this (slightly adapted) code from the documentation, we can see, that the cycler, uses the two extreme colors from the colormap.

using CairoMakie

categories = rand(1:3, 1000)
values = randn(1000)
dodge = rand(1:2, 1000)
theme = Attributes(colormap=:bluesreds)
with_theme(theme) do
CairoMakie.boxplot(categories, values, dodge = dodge, show_notch = true, color = dodge)
end

However, I would like to have the first two colors of my colormap used by the function. Any ideas and suggestions on how I can achieve this?

You need to set colorrange to (1, n) where n is the number of colors in the colormap

Mke.boxplot(categories, values, dodge=dodge, colormap=:bluesreds, colorrange=[1,8], show_notch = true, color=dodge)

(Edit: Too slow!)

These solutions do not help with coloring the outliers properly. They are still in their “original” color scheme. Additionally, is there a solution, where I can apply this systematically to an entire figure, instead of setting it manually for each subplot?

Well the documentation here seems to say that you should use

outliercolor=dodge

Colors are customizable. The color attribute refers to the color of the boxes, whereas outliercolor refers to the color of the outliers. If not scalars (e.g. :red ), these attributes must have the length of the data. If outliercolor is not provided, outliers will have the same color as their box, as shown above.

but it doesn’t seem to work like this for me when I try it.

On the other hand, if I try outliercolor=:red, this works as expected. It is as if outliercolor ignores the colormap.

outliercolor definitely seems to ignore the colormap, unless you pass it as part of the theme.

However, if you can get access to the colors you want in a vector, you can apparently do the following:

csheme = to_colormap(:bluesreds)
f = CairoMakie.boxplot(categories, values, dodge = dodge, show_notch = true,
        color = getindex.(Ref(csheme), dodge), 
        outliercolor=getindex.(Ref(csheme), dodge)
        )

Not very elegant, but functional.

Could probably be fixed by forwarding the colormap to the internal scatter plot