Skip to content

Instantly share code, notes, and snippets.

@andreas-wilm
Created November 21, 2014 03:28
Show Gist options
  • Save andreas-wilm/e374a47ddde64231aded to your computer and use it in GitHub Desktop.
Save andreas-wilm/e374a47ddde64231aded to your computer and use it in GitHub Desktop.
Use colorblind friendly cudtools as colormap
import numpy as np
import matplotlib.pyplot as plt
# use the colorblind friendly colors
# https://code.google.com/p/python-cudtools/source/browse/cudtools.py
import cudtools
numlines = 20
# normal use:
colorgen = cudtools.CUDcolorGen()
for i in range(numlines):
c = next(colorgen)
print c
# create a colormap function for cudtools
cudcmap = lambda x: cudtools.CUDcolorD[cudtools.CUDcolorOrderL[x%cudtools.LL]]
# plotting example from http://stackoverflow.com/questions/13972287/having-line-color-vary-with-data-index-for-line-graph-in-matplotlib
for (j, i) in enumerate(np.linspace(0,1, numlines)):
plt.plot(np.arange(numlines),np.tile([i],numlines),
linewidth=4, color=cudcmap(j))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment