Skip to content

Instantly share code, notes, and snippets.

@mehdirezaie
Created January 27, 2021 02:19
Show Gist options
  • Save mehdirezaie/c144c08b7a5f0b74f09ce98985e6d4bd to your computer and use it in GitHub Desktop.
Save mehdirezaie/c144c08b7a5f0b74f09ce98985e6d4bd to your computer and use it in GitHub Desktop.
Colorblind friendly colors

Colorblind friendly visualization

import matplotlib.pyplot as plt
import numpy as np
from cycler import cycler


colors = ['#377eb8', '#ff7f00', '#4daf4a',
          '#f781bf', '#a65628', '#984ea3',
          '#999999', '#e41a1c']
styles = 2*[':', '-', '--', '-.']
plt.rc('axes', prop_cycle=(cycler('color', colors)+cycler('linestyle', styles)))
                          

for i in range(len(colors)):
     x = np.linspace(0.0, np.pi)
     plt.plot(x, np.sin(x+ i*np.pi/9), label=colors[i])
plt.legend()

Screen Shot 2021-01-26 at 9 19 27 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment