Last active
May 4, 2020 11:20
-
-
Save aboucaud/2aa12cc7be62f7f3bbb94e0a87b59137 to your computer and use it in GitHub Desktop.
Extract colors from matplotlib colormap #python #visualisation
This file contains hidden or 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
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| N = 10 | |
| colors = plt.cm.viridis(np.linspace(0.25, 1.0, N)) | |
| x = np.linspace(0, 1, 30) | |
| powers = np.arange(N) + 1 | |
| for power, color in zip(powers, colors): | |
| plt.plot(x, x ** power, c=color) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment