Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

change each line color as a rainbow python

from matplotlib.pyplot import cm
import numpy as np

#variable n below should be number of curves to plot

#version 1:

color=cm.rainbow(np.linspace(0,1,n))
for i,c in zip(range(n),color):
   plt.plot(x, y,c=c)

#or version 2:

color=iter(cm.rainbow(np.linspace(0,1,n)))
for i in range(n):
   c=next(color)
   plt.plot(x, y,c=c)
Comment

PREVIOUS NEXT
Code Example
Python :: union df pandas 
Python :: filter list dict 
Python :: select text in a div selenium python 
Python :: reduce in python 
Python :: python datetime time in seconds 
Python :: how to set index pandas 
Python :: opencv save image rgb 
Python :: python watchgod 
Python :: how to draw polygon in tkinter 
Python :: load static files in django 
Python :: remove whitespace in keys from dictionary 
Python :: python get all ips in a range 
Python :: remove turtle 
Python :: dire Bonjour en python 
Python :: python define 2d table 
Python :: pandas casting into integer 
Python :: pandas to dict by row 
Python :: how to change a string to small letter in python 
Python :: how to increase size of graph in jupyter 
Python :: change the color of the button on hovering tkinter 
Python :: export csv from dataframe python 
Python :: spacy remove stop words 
Python :: python udp receive 
Python :: python selenium get title 
Python :: pandas get column values distinct 
Python :: how to roll longitude axis 
Python :: timer pythongame 
Python :: semicolons in python 
Python :: python inspect source code 
Python :: set axis plt python 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =