Skip to content

Instantly share code, notes, and snippets.

@aboucaud
Last active May 4, 2020 11:20
Show Gist options
  • Select an option

  • Save aboucaud/2aa12cc7be62f7f3bbb94e0a87b59137 to your computer and use it in GitHub Desktop.

Select an option

Save aboucaud/2aa12cc7be62f7f3bbb94e0a87b59137 to your computer and use it in GitHub Desktop.
Extract colors from matplotlib colormap #python #visualisation
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