using Plots
a = rand(Float64, 20, 5)
plot(a; linewidth=3)
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.)
What are the colors in the default palette for line graphs? Is the palette a well-known one?
Under what principle or in what scheme were these colors chosen?
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:
Is there a references or documentation for this particular palette?
Even better - the code itself… 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(
seed_colors,
lchoices = Float64[lightness],
cchoices = Float64[chroma],
hchoices = range(0; stop = 340, length = 20),
)[2:end]
ColorScheme(colors)
which generates this:
which again looks very like the default.
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 .
@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.
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
Pilestone Inc
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
A discussion of color blind friendly palettes for labeling unique catergories in data visualization.
Est. reading time: 4 minutes
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.
# . . .
ryofurue:
Is the default palette of Plots
color-blind-friendly? That is, is it designed to maximize distinction between colors for typical color-blind people?
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).
(_fill[1] == " ") && (_fill = Vector{String}()) # Passing a fill=[" "] is programatically handy to say no fill
_fill = Vector{String}()
return _fill
const matlab_cycle_colors = ["#0072BD", "#D95319", "#EDB120", "#7E2F8E", "#77AC30", "#4DBEEE", "#A2142F", "0/255/0"]
# https://en.wikipedia.org/wiki/Help:Distinguishable_colors
const alphabet_colors = ["#2BCE48", "#4C005C", "#005C31", "#5EF1F2", "#8F7C00", "#9DCC00", "#0075DC", "#94FFB5", "#740AFF", "#993F00", "#00998F", "#003380", "#191919", "#426600", "#808080", "#990000", "#C20088", "#E0FF66", "#F0A3FF", "#FF0010", "#FF5005", "#FFA8BB", "#FFA405", "#FFCC99", "#FFE100", "#FFFF80"]
# https://sashamaps.net/docs/resources/20-colors/
const simple_distinct = ["#e6194b", "#3cb44b", "#ffe119", "#4363d8", "#f58231", "#911eb4", "#46f0f0", "#f032e6", "#bcf60c", "#fabebe", "#008080", "#e6beff", "#9a6324", "#fffac8", "#800000", "#aaffc3", "#808000", "#ffd8b1", "#000075", "#808080"]
# ---------------------------------------------------------------------------------------------------
function df2ds(arg)
# If arg is a DataFrame, try to convert it into a GMTdataset. Keep all numerical columns and first Text one
(arg === nothing || isa(arg, GDtype) || isa(arg, Array)) && return arg
fs = fields(arg) # (:columns, :colindex, :metadata, :colmetadata, :allnotemetadata)
(isempty(fs) || fs[1] != :columns || fs[end] != :allnotemetadata) && return arg # Not a DataFrame
# OK, arrived here it seems arg is likely a DataFrame so try to convert it into a GMTdataset
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.
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.
Regarding this comment
ryofurue:
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.
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).
I think it would be a good thing to have a default palette that works for everyo… ne -- the current palette is not good for this (after running some plots through a simulator).
I would suggest to replace the default by:
![palette](http://mkweb.bcgsc.ca/colorblind/img/colorblindness.palettes.trivial.png)
In fact, if you tell me where to make the change, I'll be glad to submit a PR.
cormullion:
Thought Experiment: Lock 100 data scientists in a room; let them out once they’ve all agreed on the perfect color palette.
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.
ryofurue:
As @joa-quim kindly shows, List of 20 Simple, Distinct Colors | Sasha Trubetskoy
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.