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

**URL:** <https://discourse.julialang.org/t/how-can-i-change-a-single-color-in-a-plots-jl-palette/85172>\
**Category:** Visualization\
**Tags:** colors, plots\
**Created:** [August 2, 2022, 3:20pm UTC](https://discourse.julialang.org/t/how-can-i-change-a-single-color-in-a-plots-jl-palette/85172 "2022-08-02T15:20:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thompsonmj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thompsonmj/32/25172_2.png) [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Post date:** [August 2, 2022, 3:20pm UTC](https://discourse.julialang.org/t/how-can-i-change-a-single-color-in-a-plots-jl-palette/85172/1 "2022-08-02T15:20:19Z")

</div>

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

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

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

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 2, 2022, 3:47pm UTC](https://discourse.julialang.org/t/how-can-i-change-a-single-color-in-a-plots-jl-palette/85172/2 "2022-08-02T15:47:34Z")

</div>

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

```julia
c.colors.colors[10] = colorant"black" 

```

---

<div class="post-metadata">

**Author:** ![thompsonmj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thompsonmj/32/25172_2.png) [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Post date:** [August 2, 2022, 3:54pm UTC](https://discourse.julialang.org/t/how-can-i-change-a-single-color-in-a-plots-jl-palette/85172/3 "2022-08-02T15:54:20Z")

</div>

Thanks!  
Follow-up: how did you find that?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 2, 2022, 3:56pm UTC](https://discourse.julialang.org/t/how-can-i-change-a-single-color-in-a-plots-jl-palette/85172/4 "2022-08-02T15:56:44Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![thompsonmj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thompsonmj/32/25172_2.png) [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Post date:** [August 2, 2022, 4:04pm UTC](https://discourse.julialang.org/t/how-can-i-change-a-single-color-in-a-plots-jl-palette/85172/5 "2022-08-02T16:04:11Z")

</div>

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

It seems odd that

```julia
julia> c[1]
RGB{Float64}(0.1216,0.4667,0.7059)

```

and

```julia
julia> c.colors.colors[1]
RGB{Float64}(0.1216,0.4667,0.7059)

```

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