Color-blind-friendly color sequence (palette) for line graphs

I’d like to know “what” the default color sequence is for line graphs, such as the sample code below generates. In particular I’d like to know whether consideration has gone into the color palette about color blindness. If so, I’d like to read the description of the color sequence.

In this forum, there is at least one discussion thread about color-blind-friendliness among developers, but I’m not able to tell what was eventually agreed upon.

I started to read the source codes under PlotThemes.jl but I’m struggling to locate the place where the actual colors are defined. Maybe that’s the wrong place.

using Plots
a = rand(Float64, 20, 5)
plot(a; linewidth=3)

ColorCET is probably a good starting point. A lot of efforts are derived from that work

https://colorcet.com/

1 Like

See this ColorSchemes.jl section too.

1 Like

Thank you folks, but it seems that I didn’t write my initial post clearly. I know those works you refer to (not those particular references, but the works those references are based on).

All I want to find out is the description of the default palette. (By extension, I’d also like to know what other palettes are.)

  1. What are the colors in the default palette for line graphs? Is the palette a well-known one?
  2. Under what principle or in what scheme were these colors chosen?
  3. Is there a references or documentation for this particular palette?

For example, I use Viridis and Parula, which are color-blind-friendly and perceptually uniform, for my contour plots. I often use “Tol Bright”, which is included in the reference @rafael.guerra cites, for line graphs. Both are on a graphing app which isn’t Julia.

Julia’s default palette looks similar to Tol Bright but the order of the colors is different. (Come to think of it, order shouldn’t matter and Julia’s default may be To Bright.)

So, what is the default palette? (I’m willing to look into the source codes, if I know where to look.)

If there is no documentation for the default palette, I’d like to know how to plug in a custom palette. I’d use Tol Bright for my line graphs. (I’ll start to research into it tomorrow.)

All I want to find out is the description of the default palette. … So, what is the default palette?

I think this is the default palette, according to the manual:

Looks very like the default legend for a plot:

  1. Is there a references or documentation for this particular palette?

Even better - the code itself… :slight_smile: After a bit of spelunking, I think the default palette is generated with this code:

function generate_colorscheme(
    bgcolor = plot_color(:white);
    color_bases = plot_color([colorant"steelblue", colorant"orangered"]),
    lightness = lightness_from_background(bgcolor),
    chroma = _lch_c_const[],
    n = 17,
)
    seed_colors = vcat(bgcolor, map(c -> adjust_lch(c, lightness, chroma), color_bases))
    seed_colors = convert(Vector{RGB{Float64}}, seed_colors)
    colors = distinguishable_colors(
        n,
        seed_colors,
        lchoices = Float64[lightness],
        cchoices = Float64[chroma],
        hchoices = range(0; stop = 340, length = 20),
    )[2:end]
    ColorScheme(colors)
end

which generates this:

which again looks very like the default.

  1. Under what principle or in what scheme were these colors chosen?

Well, Plots.jl has quite a long and interesting history - quite a few things have been discussed in the 2,500 or so issues on github.com, and many people have contributed to its development over the years. If you search through the issues, you’ll find many discussions about many aspects of plot generation. But I’d guess that using Colors.distinguishable_colors was a reasonable principle to adopt at the time.

I’d like to know how to plug in a custom palette

I think the docs cover most of the basics.

If you want to create custom colorschemes, this is possible using functions from Colors.jl - or you could experiment with ColorSchemeTools.

2 Likes

@cormullion, there was probably a lot of science in that palette, but it’s pretty weird…
Something like this List of 20 Simple, Distinct Colors, seems more obvious.

1 Like

Thought Experiment: Lock 100 data scientists in a room; let them out once they’ve all agreed on the perfect color palette. :grinning:

3 Likes

Okay, it seems that I have to drastically simplify my question.

  • Is the default palette of Plots color-blind-friendly? That is, is it designed to maximize distinction between colors for typical color-blind people?

Where can I find the answer to this question?

. . . But it seems to me that the answer is yes and no . . . I’ve tested the generated palette (Thanks, @cormullion !) on

and found a typical color-blind person can tell the first 7 colors apart but if you include the remaining colors, some of the colors look alike.

So, my guess is that it’s designed to be color-blind friendly as long as you stick to the first 7 colors. The first 7 colors look similar to “Tol Bright” (see below) though in a different order.

You or we definitely need a documentation that discusses this property of the default palette. The above is just my guess. We’d need to track down the person who wrote the code and ask her/him to describe the palette. How do I go about it?


The following discussion is now moot.

“Is there a references or documentation for this particular palette?”

Even better - the code itself

I’m afraid it’s not! I’m looking for a reference like this

This article clearly describes how and for what purposes the palettes like “Tol Bright” have been constructed and what properties they have.

When I said I don’t mind reading the source code, I imagined references would be found in the comments! If I were to write a code to construct a palette, I would write it as

# The default palette is based on "Tol Bright"
# (https://thenode.biologists.com/data-visualization-with-flying-colors/research/).
# The original palette has only 7 colors. In the following code, I increase it to 12
# by such and such a method. This somewhat decreases distinctiveness, but I've
# checked the result using the color-blind simulator (https://sample.org/ . . . )
# and it looked fine.
# . . .
1 Like

Are you kidding? I’m not colorblind and I can’t even distinguish between anything after the first 7. But I think using too many colors in one plot is bad. I would stick to 4/5 at most and then start varying line styles if needed (actually I prefer to vary line styles first to make the plots bw printer friendly).

1 Like
1 Like

Are you kidding? I’m not colorblind and I can’t even distinguish between anything after the first 7.

I apologize if I offended you for some reason, but honestly I don’t understand what you are attacking.

If you don’t choose the colors carefully, even the first 7 colors may not be distinguishable to color blind people. That’s the point of the newer color schemes like those Paul Tol constructed. In that sense, Julia’s default color scheme is an improvement over the traditional red, blue, green, . . . scheme.

Then the additional colors Julia offers represent somebody’s efforts to add more colors that are distinguishable to people with normal vision . . . that’s my guess. And I believe your

“I can’t even distinguish between anything after the first 7”

is an exaggeration. At least I can distinguish them if I look carefully.

So, Julia’s default color scheme seems to represent best efforts by somebody, to maximize its utility both to color-blind people and to people with normal vision.

All I’m asking for is a documentation that summarizes these efforts.


The following is a tangential issue:

I would stick to 4/5 at most and then start varying line styles if needed

I agree. I wish that were the default behavior. The point of default is to produce as legible a result as possible without user intervention.

Not attacking anyone – I was being facetious. And what I meant about beyond 7 was that for example if you include 5/8/10 in the same plot (with or without other colors), it would be nearly indistinguishable. Or 1 and 13.

It is possible that the colorscheme was not designed with this in mind, an there may not be such a documentation already written. The piece of code referenced earlier was commited by @daschw some maybe he has some insight?

However, I agree it would be a nice discussion to have in the Plots.jl github repo, although we should not lose sight that while it is the default, it is always easy to select any other colorscheme so while I do think that the the default is important it may not be THAT important.

P.S
Regarding this comment

Be wary that this is not “Julia’s default scheme” but rather Plots.jl default scheme. While Plots.jl is a prominent plotting package is not integrated in the julia language. Other plotting packages have different defaults. For example, Makie uses the so-colled “Wong colors” from here Points of view: Color blindness | Nature Methods (but that were originally published by Masataka Okabe & Kei Ito in 2003).

By the way. I found this discussion in Plots’ repository, it may be interesting to take a look at it:

1 Like

So either they are colorblind or they are crazy:

Thank you everyone for helping. Sorry I don’t have much time right now to address all comments. I intend to come back in several weeks.

Perhaps I should have explained why I need the documentation in the first place.

I plot 10 curves in 10 different colors using the Plots package’s default. As you can imagine, it’s not easy to distinguish them. But the purpose of the plot is to show the reader general properties of the 10 curves, and for this very reason, I don’t want to use thick lines, symbols, or dashes, because those distinctions would emphasize some curves and de-emphasize some others curves.

So, the ability to distinguish the colors isn’t a primary concern for this particular plot. Still, it would be nice if the interested reader can distinguish the curves even if that would require zooming into the plot and carefully comparing the lines against the legend. The reader might want to do this for a purpose I don’t foresee.

I submitted a paper including this plot. Then a reviewer casually asks to improve the color scheme of the plot. I plan to answer that there are better color schemes for people with normal vision but to be inclusive for color blind people, probably this is the best, or at least one of the best color schemes.

To write this answer, I wanted a documentation of this particular palette. As @joa-quim kindly shows, List of 20 Simple, Distinct Colors | Sasha Trubetskoy
is the documentation I’ve been looking for. Unfortunately the document touches upon color blindness only in general terms. But as I said before, I tested the scheme at a color-blind simulator and saw that at least the first 7 colors must have been designed color blindness in mind.

The first link was from @rafael.guerra

To setup a colorblind friendly palette you can read a few journal papers on this topic. In this way you can select colors based on rigorous, scientific arguments.
https://www.nature.com/articles/d41586-021-02696-z
https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0249755
and this older (2018) paper, by the cividis colormap authors:
[Optimizing colormaps with consideration for color vision deficiency to enable accurate interpretation of scientific data

Trubeskoy’s colors are distinguishable for people with “normal” vision, but according to standards for colorblind friendly palettes, some of his colors are too bright.

In his site, Trubeskoy provides palettes for 95%, 99%, 99.99% and 100% population accessibility.

1 Like

Yes he did, but without arguments. Are there posted somewhere the results of his experiments, the sample size, questions addressed to participants?