Answers for "matplotlib: use colormaps for line plot colors"

0

matplotlib: use colormaps for line plot colors

import numpy as np
import matplotlib.pylab as plt
plt.rcParams["figure.figsize"] = [7, 7]
plt.rcParams["figure.autolayout"] = True
x = np.array([0,1])
y = np.array([1,1])
n = 50
colors = plt.cm.hsv(np.linspace(0, 1, n))
for i in range(n):
    plt.plot(x,y * i, color=colors[i])
plt.show()
Posted by: Guest on June-08-2021

Python Answers by Framework

Browse Popular Code Answers by Language