I just increase my sample to 12 and found axes.prop_cycle()
has only 10 colors by default (I think it is tab10
.). So I got IndexError: list index out of range
.
My simplified code. Each sample value is represented in each row of matrix
matrix = np.random.randint(25, size=(12, 4))
for p in xrange(12):
ax_eachp = plt.subplot2grid((protcount, 1), (p, 0), rowspan=1, colspan=1)
ax_eachp.plot(matrix[p], color=colors[p])
Can I just add 2 more colors manually if I want to remain first 10 colors in tab10
? or how to change to other qualitative color maps?
Just as the linked question Python Matplotlib/Basemap Color Cycling shows, you may set the axes'
prop_cycle
to include those colors you like.Here you can take the tab10 colors and add two more colors to the list of colors to be used in the
prop_cycle
.However, since in the case from the question, you anyway loop over the colors, there is actually no need for a cycler. The following produces the same result as above.