# Issues setting palette to matlplotlib's "tab10" colors

**URL:** <https://discourse.julialang.org/t/issues-setting-palette-to-matlplotlibs-tab10-colors/38661>\
**Category:** Visualization\
**Tags:** question, plotting\
**Created:** [May 3, 2020, 10:55am UTC](https://discourse.julialang.org/t/issues-setting-palette-to-matlplotlibs-tab10-colors/38661 "2020-05-03T10:55:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rouzaire](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@Rouzaire](https://discourse.julialang.org/u/Rouzaire)\
**Post date:** [May 3, 2020, 10:55am UTC](https://discourse.julialang.org/t/issues-setting-palette-to-matlplotlibs-tab10-colors/38661/1 "2020-05-03T10:55:57Z")

</div>

Hello,

I’ve been trying to plot curves with the colors of matplotlib’s palette `:tab10` but I can’t find the solution, even after removing and reinstalling Plots and ColorSchemes.  
Here are the desired colors :

 ![tab10palette](https://global.discourse-cdn.com/julialang/original/3X/a/8/a8bd9ad8aead03e897453a7a0afe01ce93453d11.png)

- When I run `palette(:auto)` , I do obtain a 17-element `Vector{RGBA{Float64}}`, and it’s correctly plotted in the Plot panel of Juno.
- When I run `palette(:tab10)`, I obtain the exact same palette as in the previous bullet point : first departure from the [documentation](https://docs.juliaplots.org/latest/generated/colorschemes/#ColorPalette-1). Note that I recover the correct palette running `colorschemes[:tab10]`, which type is `ColorScheme{some_array}`.
- The same doc states that " Color palettes can be constructed with `palette(cs, [n])` where `cs` can be a `Symbol` , a vector of colors, a `ColorScheme` , `ColorPalette` or `ColorGradient`". Yet, when running `palette(colorschemes[:tab10])`, I get `no method matching palette(::ColorScheme{StaticArrays.SArray{Tuple{10},RGB{Float64},1,10},String,String})`
- Then I tried passing a `ColorGradient` : `plot(data,palette=cgrad(colorschemes[:tab10].colors)` but it doesn’t output what I want : ![issue_colors](https://global.discourse-cdn.com/julialang/original/3X/7/f/7fa2943f6c635bc7b25b78039352ac951f04ba54.png)

I am a bit confused, could you help me out ? Once this is done, is it possible to make this palette a default one, meaning that no operation would be necessary at the opening of a new Julia session in order to work with the `:tab10`colors ?

Thank you very much in advance !

* * *

Some additional info :

```julia
cgradients() = Symbol[:blues, :viridis, :pu_or, :magma, :plasma, :inferno]
clibraries() = Symbol[:Plots, :cmocean, :misc, :colorcet, :colorbrewer]

```

while the desired palette `:tab10`, according to [this page](http://juliagraphics.github.io/ColorSchemes.jl/stable/basics/#matplotlib-1), is located in the `matplotlib` library.

Versions of packages :

```julia
"ColorSchemes" => v"3.9.0" , "Plots" => v"0.29.9","PyPlot" => v"2.8.2" , "Juno" => v"0.8.1" , "Atom" => v"0.12.10"

```

---

<div class="post-metadata">

**Author:** ![josephmarturano](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@josephmarturano](https://discourse.julialang.org/u/josephmarturano)\
**Post date:** [May 7, 2020, 10:33am UTC](https://discourse.julialang.org/t/issues-setting-palette-to-matlplotlibs-tab10-colors/38661/2 "2020-05-07T10:33:48Z")

</div>

I am not sure if this helps you, but when I pass the whole tab10 palette to plots, an incorrect colorscheme shows up in the plot. But when I pass a truncated palette that matches the number of groups in the plot, I get back the correct colors, i.e., the difference in the palette keyword below:

```julia
using Plots, ColorSchemes
gr()

fullpalette = plot(1:100, rand(100), group=repeat([1,2,3,4,5], inner=20), lw=3, palette=ColorSchemes.tab10.colors, title="Full palette");
truncatedpalette = plot(1:100, rand(100), group=repeat([1,2,3,4,5], inner=20), lw=3, palette=ColorSchemes.tab10.colors[1:5], title="Truncated palette");

combinedplot = plot(fullpalette, truncatedpalette, size=(1600,800))
savefig(combinedplot, "tab10_colorschemes.png");

```

Which produces the following:

 ![tab10_colorschemes](https://global.discourse-cdn.com/julialang/original/3X/c/a/ca8e8ae97fc27b30134b11b432dab23e8d730637.png)

---

<div class="post-metadata">

**Author:** ![Rouzaire](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@Rouzaire](https://discourse.julialang.org/u/Rouzaire)\
**Post date:** [May 22, 2020, 5:01pm UTC](https://discourse.julialang.org/t/issues-setting-palette-to-matlplotlibs-tab10-colors/38661/3 "2020-05-22T17:01:08Z")

</div>

> [@josephmarturano](#):
>
> `palette=ColorSchemes.tab10.colors[1:5]`

Great, thank you very much, problem solved !

I should add that even if the plot contains only (say) 2 curves, systematically adding [1:10] ( `palette=ColorSchemes.tab10.colors[1:10]`) forces the 2 curves to adopt the first 2 colors of the desired palette.
