How can I change a single color in a Plots.jl palette?

If I have a palette, is there some way to change the colors by index?

c = palette(:tab10)
c[10] = colorant"black"

ERROR: MethodError: no method matching setindex!(::ColorPalette, ::RGB{N0f8}, ::Int64)

This seems to work, but I have no clue why we have to dig so deep:

c.colors.colors[10] = colorant"black" 
1 Like

Follow-up: how did you find that?

Digging in the REPL with dot-TAB. Type c. <TAB> to find out that c is a rich object with fields. Then do the same for c.colors. <TAB>, and keep digging on…

Nice, I’ll add the dot-tab shovel to my toolkit.

It seems odd that

julia> c[1]


julia> c.colors.colors[1]

but you can’t assign a value to the first.