X = [22, 33 , 55 , 66 , 77 ,55, 66, 77, 44, 66, 33] Y = [2, 6 , 9 , 9 , 10 ,5, 32, 19, 123, 46, 93]
list = [0, 1, 2, 3 ,4, 0, 5, 6 , 7 ,0 , 8 , 9 ,10,0]
x and y are the cordinates list represent an algorithm output sequence
using list I need to plot different colour, in this example: 1, 2, 3 ,4 -- ColorA 5, 6 , 7 -- ColorB 8 , 9 ,10 -- ColorC or a line link the paths : 0,1, 2, 3 ,4,0 -- lineA 0, 5, 6 , 7 ,0 -- lineB 0, 8 , 9 ,10, 0 -- lineC
I tried this code
Xsolution = []
Ysolution = []
for i in range(len(list)):
Xsolution.append(X[list[i]])
Ysolution.append(Y[list[i]])
if list[i] == 0 :
plt.scatter(Xsolution, Ysolution, color=random_color())
Xsolution = []
Ysolution = []
I need a function that generate a random colour every time list[i] is 0