[PYTHON] Try to make matplotlib's color cycle look good

What is a color cycle?

スクリーンショット 2019-12-05 10.39.38.png

With this kind of feeling, if you plot multiple plots on one figure by default, the color will change like "blue → orange → green → red ...". When the number of plots exceeds 10, it goes around and returns to blue again.

Let's call this the color cycle [^ 1].

Mostly, I refer to skotaro's article [^ 1]. great.

Why is this color?

According to skotaro's article [^ 1], this is also the default color of tableau in the past [^ 2].

tableau10_palette.png

As you can see from this figure, the old colors are quite vivid and not very easy on the eyes. So let's start with a new tableau color.

Changed to the current (?) Tableau color.

from matplotlib import pyplot as plt
from cycler import cycler

plt.rcParams['axes.prop_cycle']  = cycler(color=['#4E79A7', '#F28E2B', '#E15759', '#76B7B2','#59A14E',
                                                 '#EDC949','#B07AA2','#FF9DA7','#9C755F','#BAB0AC'])

x_list = [[i for i in range(11)] for _ in range(11)]
y_list = [[i for _ in range(11)] for i in range(11)]

for x,y in zip(x_list,y_list):
    plt.plot(x,y,linewidth=10.)

スクリーンショット 2019-12-05 10.42.47.png

Color extraction was done using a very convenient site [^ 3]. The color is kind to the eyes! !!

Don't you use 10 colors?

Using as many as 10 colors will result in poor visibility. Therefore, consider a setting that uses the same type of color.

Beautiful Blues[1]

blue_cycle = cycler(color=['#011f4b','#03396c','#005b96','#6497b1','#b3cde0'])
plt.rcParams['axes.prop_cycle']  = blue_cycle

for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 10.57.21.png

Number3[1:1]

number3_cycle = cycler(color=['#2a4d69','#4b86b4','#adcbe3','#e7eff6','#63ace5'])
plt.rcParams['axes.prop_cycle']  = number3_cycle

for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.00.58.png

Pastellea[1:2]

pastellea_cycle = cycler(color=['#fe9c8f','#feb2a8','#fec8c1','#fad9c1','#f9caa7'])
plt.rcParams['axes.prop_cycle']  = pastellea_cycle
for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.04.15.png

Android Lollipop[1:3]

android_lollipop_cycle = cycler(color=['#009688','#35a79c','#54b2a9','#65c3ba','#83d0c9'])
plt.rcParams['axes.prop_cycle']  = android_lollipop_cycle
for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.07.17.png

blue gray[1:4]

blue_grey_cycle = cycler(color=['#6e7f80','#536872','#708090','#536878','#36454f'])
plt.rcParams['axes.prop_cycle']  = blue_grey_cycle
for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.11.46.png

Gray Blue[1:5]

gray_blue_cycle = cycler(color=['#3385c6','#4279a3','#476c8a','#49657b','#7f8e9e'])
plt.rcParams['axes.prop_cycle']  = gray_blue_cycle
for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.16.57.png

Purple Skyline[1:6]

purple_cycle = cycler(color=['#2e003e','#3d2352','#3d1e6d','#8874a3','#e4dcf1'])
plt.rcParams['axes.prop_cycle']  = purple_cycle
for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.19.45.png

Skin Tones[1:7]

skin_cycle = cycler(color=['#8d5524','#c68642','#e0ac69','#f1c27d','#ffdbac'])
plt.rcParams['axes.prop_cycle']  = skin_cycle
for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.22.16.png

Space Gray[1:8]

space_gray_cycle = cycler(color=['#343d46','#4f5b66','#65737e','#a7adba','#c0c5ce'])
plt.rcParams['axes.prop_cycle']  = space_gray_cycle
for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.24.14.png

The Armor Falls[1:9]

armor_falls_cycle = cycler(color=['#bfd6f6','#8dbdff','#64a1f4','#4a91f2','#3b7dd8'])
plt.rcParams['axes.prop_cycle']  = armor_falls_cycle
for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.26.24.png

Blue palette [2]

blue_cycle2 = cycler(color=['#005073','#107dac','#189ad3','#1ebbd7','#71c7ec'])
plt.rcParams['axes.prop_cycle']  = blue_cycle2
for x,y in zip(x_list[:5],y_list[:5]):
    plt.plot(x,y,linewidth=30.)

スクリーンショット 2019-12-05 11.31.00.png


  1. https://digitalsynopsis.com/design/beautiful-color-palettes-combinations-schemes/ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

  2. https://www.color-hex.com/color-palette/30415 ↩︎

Recommended Posts

Try to make matplotlib's color cycle look good
Try to make a kernel of Jupyter
Try to make something like C # LINQ
Try to make your own AWS-SDK with bash
AI beginners try to make professional student bots
Try to make a "cryptanalysis" cipher with Python
Try to make a dihedral group with Python
Try to make client FTP fastest with Pythonista
Try to make a Python module in C language
Try to make a command standby tool with python
Try to make RESTful API with MVC using Flask 1.0.2
Machine learning beginners try to make a decision tree