How to set a custom theme in Plots.jl

Hi,

I’m new to Julia and I want to setup a custom plotting theme. I’ve checked here http://docs.juliaplots.org/latest/generated/plotthemes/ and it points to the package PlotThemes (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 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):

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

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!

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

1 Like

Adding using Colorsdid solve my error. However now I get

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

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

1 Like