A Byte of my 2.2-lb Brain

Just sharing stuff…

Tableau Colors in Matplotlib

I love the colors that Tableau uses in plotting. I was so happy I came across Randal Olson’s post titled “How to make beautiful data visualizations in Python with matplotlib.” You can read the entire post here. For my own convenience, however, I am reposting a snippet of his code (including the comments) on the Tableau colors below.

# These are the "Tableau 20" colors as RGB. 
tableau20 = [(31, 119, 180), (174, 199, 232), (255, 127, 14), (255, 187, 120), 
 (44, 160, 44), (152, 223, 138), (214, 39, 40), (255, 152, 150), 
 (148, 103, 189), (197, 176, 213), (140, 86, 75), (196, 156, 148), 
 (227, 119, 194), (247, 182, 210), (127, 127, 127), (199, 199, 199), 
 (188, 189, 34), (219, 219, 141), (23, 190, 207), (158, 218, 229)] 
 
# Scale the RGB values to the [0, 1] range, which is the format matplotlib accepts. 
for i in range(len(tableau20)): 
 r, g, b = tableau20[i] 
 tableau20[i] = (r / 255., g / 255., b / 255.) 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on September 2, 2015 by in Geek and tagged , , .
%d bloggers like this: