Home > Software engineering >  How can I get a color map from a list?
How can I get a color map from a list?

Time:09-08

I am beginner developer and I encountered a problem.

I tried to plot using matplotlib in python with different colors. I depicted the problem I have as simple as possible below.

list = [5,4,8]
x = [1,2,3,4]
y = [1,2,3,4]

for i in range(len(list)):
   plt.plot((x[i], x[i 1]), (y[i], y[i 1]), color = ?list?) 

As you notice, there are three different straight lines. I want to color them with different colors. Ultimately, I want to convert the above list into a color map or a cmap which are available to apply for matplotlib.plot.

Sorry for my humble english. I hope experts in stackoverflow help me for this problem.

CodePudding user response:

You should avoid naming a variable list, as this is the Python command to make a list. You could pick colors from the enter image description here

  • Related