Color defined externally Makie

I want to put the color from a defined string flag

grey_flag = 1

fig_color = "white"
if grey_flag == 1
    fig_color = "#f5f0f5"
end


f = Figure(backgroundcolor = :fig_color)

It throws an error as it attempts to see fig_color from the default colors of the package.

How can i achieve this?

The issue is that the : prefix in Julia denotes a “symbol”, which means the function thinks you want a color named :fig_color, not a color whose name is contained in the variable fig_color. Remove the : and you should be fine!

2 Likes