As a colorblind person I find the matplotlib sytle 'tableau-colorblind10' great to work with.
It is as simple as adding to your code these lines:
import matplotlib.pyplot as plt
plt.style.use('tableau-colorblind10')
I can easily distinguish the colors from each other, however I have difficulties naming the colors when I'm showing the plots to my colleagues.
Does Matplotlib have color names (non hex code) for this sytle? I only found a handful of colors that have official names (strings such as 'blue', 'red', etc.) associated with them.
Anyway, the matplotlib hex codes for the tableau-colorblind10 style are here. And this very useful website tells you the color names from its HEX code (or RGB or HSB)
Using both, here's the list of color names for 'tableau-colorblind10' matplotlib sytle:
Hex | Color name/hue |
---|---|
'006BA4' | Cerulean/Blue |
'FF800E' | Pumpkin/Orange |
'ABABAB' | Dark Gray/Gray |
'595959' | Mortar/Grey |
'5F9ED1' | Picton Blue/Blue |
'C85200' | Tenne (Tawny)/Orange |
'898989' | Suva Grey/Grey |
'A2C8EC' | Sail/Blue |
'FFBC79' | Macaroni And Cheese/Orange |
'CFCFCF' | Very Light Grey/Grey |
Hope some of you find this as useful as I did.
UPDATE
There are numerous possible colors can be displayed on your screen among which few are named by human with a human-readable name. Therefore you can hardly get a unique name from any possible RGB value or hex code. However, if you really need a method, there's a way based on KNN algorithm.
Infer Human-Readable Names for Any Possible Colors
I encapsuled a class with all CSS name data stored in
matplotlib.colors
and implemented a KNN algorithm in it like this:And when it goes to your specific question, you just do this:
You can see the result is:
The algorithm helps you find
k
nearest named colors in the RGB color space (you can specify the value ofk
whatever you want, and here in my above codek=3
), return the distance and the names for you. For example:This line means the color
#006BA4
is nearest darkcyan and also similar with teal, besides those two colors, is also slightly like steelblue, according to the distances specified in breckets.There's a
_color_data.py
file inmatplotlib
stores all the color names and its hex code. I suppose that's what you want and you can either check it directly here on github or do something like this:where
BASE_COLORS
,CSS4_COLORS
, ... are alldict
s with human-readable names as keys and hex codes or rgb tuples as values.