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)
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"
Thanks!
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]
RGB{Float64}(0.1216,0.4667,0.7059)
and
julia> c.colors.colors[1]
RGB{Float64}(0.1216,0.4667,0.7059)
but you can’t assign a value to the first.