of this question link I managed to paint a graphic with different colors depending on an "annotation" binary array. The problem is that now I want to use three colors and I do not understand the for loop too well. I've tried it with an elif -a but it gives me syntax problems. The code I have, from the link is as follows:
x = time # resampledTime
y = feature # modulusOfZeroNormalized
annotation = diarization==0
# set up colors
c = ['r' if a else 'g' for a in annotation]
# convert time series to line segments
lines = [((x0,y0), (x1,y1)) for x0, y0, x1, y1 in zip(x[:-1], y[:-1], x[1:], y[1:])]
colored_lines = LineCollection(lines, colors=c, linewidths=(2,))
# plot data
fig, ax = plt.subplots(1)
ax.add_collection(colored_lines)
ax.autoscale_view()
plt.text(0, 0.9*np.max(feature), feature_name)
plt.show()
My vector diarization will now bring zeros, some and less ones only but with the code now it paints in red the 0 and the rest in green. Does anyone know how to modify the line c = ['r' if ......] so that it takes into account three colors? PS: with elif it does not let me do anything for syntax errors.
Thank you.