-
-
Save amrakm/479270c2d1c0f7f714ea2950a22dad5f to your computer and use it in GitHub Desktop.
Get a list of n hex colors for a given matplotlib palette
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://stackoverflow.com/a/33597599/5391200 | |
from pylab import * | |
cmap = cm.get_cmap('seismic', 5) # matplotlib color palette name, n colors | |
for i in range(cmap.N): | |
rgb = cmap(i)[:3] # will return rgba, we take only first 3 so we get rgb | |
print(matplotlib.colors.rgb2hex(rgb)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment