Plots: JuliaGraphics / Colors.jl removing the guess of colours

We are ever so grateful of having such a great variety of colour options in Plots which is great for publications. But the question is how can we get a preview of the colour before trying them out?

Colours


# This is the union of every color defined in X11 and in SVG, prefering the SVG
# definition when they clash.
const color_names = Dict(
    "aliceblue"            => (240, 248, 255),
    "antiquewhite"         => (250, 235, 215),
    "antiquewhite1"        => (255, 239, 219),
    "antiquewhite2"        => (238, 223, 204),
    "antiquewhite3"        => (205, 192, 176),
    "antiquewhite4"        => (139, 131, 120),
    "aqua"                 => (  0, 255, 255),
    "aquamarine"           => (127, 255, 212),
    "aquamarine1"          => (127, 255, 212),
    "aquamarine2"          => (118, 238, 198),
    "aquamarine3"          => (102, 205, 170),
    "aquamarine4"          => ( 69, 139, 116),
etc...

It will be amazing if we can get something like:

Many thanks for any help you may provide,
Joseph

The xcolor docs has a section that lists them all (“colors by name”):

http://mirrors.ctan.org/macros/latex/contrib/xcolor/xcolor.pdf

Your TeX installation may have a local copy, too, use texdoc xcolor or similar to access it.

You could try diving into the Colors.jl package and display a chart. In a terminal:

open .julia/packages/Colors/kc2v8/images/color_names_sorted.svg

On my Mac this opens in the Safari web browser. The kc2v8 is the package ID, it might be different for you…

Finally in a VSCode or IJulia terminal (probably Pluto too?) if you just let a color value display it will show as the color.

3 Likes

To expand on @tim.holy’s answer, running the following in IJulia will show the name and color (as a 25x25 mm square) for every color defined in that file:

using Colors
for c in Colors.color_names
    display(c.first)
    display(RGB((c.second./255)...))
end

image

Or to get a more compact output:

using Colors
for (name, code) in Colors.color_names
    rgb = RGB((code./255)...)
    rgb_html = "<span style='background-color: #$(hex(rgb)); padding: 10px;'/>"
    display("text/html", "$rgb_html $name")
end

image

4 Likes

It is so amazing to have such a vibrant community :relieved:. I am wandering if we can update the website to include a link to a pdf file with the name of the colour and the colour sample as you kindly showed above:
https://github.com/JuliaGraphics/Colors.jl/blob/master/src/names_data.jl

The Colors.jl documentation has http://juliagraphics.github.io/Colors.jl/stable/namedcolors/

Is this what you had in mind?

2 Likes

Perhaps OP was working offline… It’s not easy to browse the documentation for Julia packages if you’re off-line - the downloaded package contains the documentation sources, but it doesn’t have the built HTML files.

A great thanks for providing me the solution to our question.

Will you kindly update the website to link:
https://github.com/JuliaGraphics/Colors.jl/blob/master/src/names_data.jl

With
http://juliagraphics.github.io/Colors.jl/stable/namedcolors/

Thanks,
Joseph

This is twice the same URL… Do you want to modify http://juliagraphics.github.io/Colors.jl/stable/namedcolors/ to link to the source code? You can propose the change yourself: click on “Edit on GitHub” in the top right corner of that page, then click on the pencil icon to propose a change.