Add named colors and use them in PlotlyJS

First, I am not sure how to properly add named colors to Colors.jl - I think that might be the main problem.
I managed to (apparently) add a named color by running:

using Colors
Colors.color_names = merge!(Colors.color_names, Dict("myred" => (202,29,39)))

In VSCode for example I can see a patch with the proper color by typing:


But I can’t seem to be able to use that color in PlotlyJS as easily as predefined colors. This works:

using PlotlyJS
plot(scatter(; x=[1,2,3], y=[5,1,5], line_color=colorant"myred"))

But if I try the shorter forms, e.g.

plot(scatter(; x=[1,2,3], y=[5,1,5], line_color="myred"))
plot(scatter(; x=[1,2,3], y=[5,1,5], line_color=:myred))

I get a blue line (the default, as if line_color was not “seen”). replacing myred with red for example gets me a red line, so it seems that my added color (myred) is not “as visible” to PlotlyJS as the predefined ones.
Is there any way to “really” add named colors that would be treated as the default ones?

1 Like