# How to set a custom theme in Plots.jl

**URL:** <https://discourse.julialang.org/t/how-to-set-a-custom-theme-in-plots-jl/44545>\
**Category:** New to Julia\
**Created:** [August 8, 2020, 3:00am UTC](https://discourse.julialang.org/t/how-to-set-a-custom-theme-in-plots-jl/44545 "2020-08-08T03:00:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![h4pZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/h4pz/32/16865_2.png) [@h4pZ](https://discourse.julialang.org/u/h4pZ)\
**Post date:** [August 8, 2020, 3:00am UTC](https://discourse.julialang.org/t/how-to-set-a-custom-theme-in-plots-jl/44545/1 "2020-08-08T03:00:24Z")

</div>

Hi,

I’m new to Julia and I want to setup a custom plotting theme. I’ve checked here [Themes · Plots](http://docs.juliaplots.org/latest/generated/plotthemes/) and it points to the package `PlotThemes` ([https://github.com/JuliaPlots/PlotThemes.jl](https://github.com/JuliaPlots/PlotThemes.jl)).

Using the themes from the library `PlotThemes` is pretty straight forward. However I’m baffled because I can’t figure out how to create my own!

I’ve copied this file [https://github.com/JuliaPlots/PlotThemes.jl/blob/master/src/dark.jl](https://github.com/JuliaPlots/PlotThemes.jl/blob/master/src/dark.jl) and changed its name to `custom.jl` and also changed the line number 10 to `_themes[:custom] = PlotTheme(`

Then I ran the following script (which obviously doesn’t work):

```julia
import Plots

include("custom.jl")

Plots.theme(:custom)

x = collect(1:1/100:10);
y = sin.(x);

Plots.plot(x, y)

```

Which throws the following error

```julia
ERROR: LoadError: LoadError: UndefVarError: @colorant_str not defined
Stacktrace:
 [1] top-level scope
 [2] top-level scope at REPL[1]:1

```

I don’t know what to do and also I don’t know where the function `expand_palette` is coming from (line 20 of `dark.jl`).

Please guide me on to how to create my own color scheme. I have my own matplotlib style that I wish to use in Julia!

---

<div class="post-metadata">

**Author:** ![jonniedie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonniedie/32/12842_2.png) [@jonniedie](https://discourse.julialang.org/u/jonniedie)\
**Post date:** [August 8, 2020, 3:29am UTC](https://discourse.julialang.org/t/how-to-set-a-custom-theme-in-plots-jl/44545/2 "2020-08-08T03:29:45Z")

</div>

You have to either `using Colors` or `using PlotUtils`, which re-exports Colors.

---

<div class="post-metadata">

**Author:** ![h4pZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/h4pz/32/16865_2.png) [@h4pZ](https://discourse.julialang.org/u/h4pZ)\
**Post date:** [August 8, 2020, 3:39am UTC](https://discourse.julialang.org/t/how-to-set-a-custom-theme-in-plots-jl/44545/3 "2020-08-08T03:39:32Z")

</div>

Adding `using Colors`did solve my error. However now I get

```julia
ERROR: UndefVarError: expand_palette not defined
Stacktrace:
 [1] top-level scope
 [2] top-level scope at REPL[1]: 

```

---

<div class="post-metadata">

**Author:** ![h4pZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/h4pz/32/16865_2.png) [@h4pZ](https://discourse.julialang.org/u/h4pZ)\
**Post date:** [August 8, 2020, 3:41am UTC](https://discourse.julialang.org/t/how-to-set-a-custom-theme-in-plots-jl/44545/4 "2020-08-08T03:41:04Z")

</div>

Wait, never mind. I see that function is defined here [https://github.com/JuliaPlots/PlotThemes.jl/blob/master/src/PlotThemes.jl](https://github.com/JuliaPlots/PlotThemes.jl/blob/master/src/PlotThemes.jl) on line 12.
