Context:
- 3x35
valuesarray that associates 1 value per segment - 4x35x2
matposarray that gathers the coordinates of 4x35 points (hence 3x35 segments).
Question:
How can I define each segment's color based on their values from the values array ?
Code attempt:
# Array of values for each point
values = np.random.rand(3,35)
# Generate array of positions
x = np.arange(0,35)
y = np.arange(0,4)
matpos = np.array([[(y[i], x[j]) for j in range(0,len(x))] for i in range(0,len(y))])
# plot the figure
plt.figure()
for i in range(len(y)-1):
for j in range(len(x)):
# plot each segment
plt.plot(matpos[i:i+2,j,0],matpos[i:i+2,j,1]) #color = values[i,j]