I was trying to plot a 2D array vs a 1D array with pyplot. I can do that with no problems and columns in the 2D array are treated like two different sets of Y datas, which is what i want. What i don't know is how to specify a different color for every column in the 2d array. if i use pyplot.plot(1darray, 2darray, "r-") every column in 2d array is plotted red for example. Should i modify the standard color map or is there a smarter way?
1 Answer
If you want to use custom colors for each column, then the best approach is to plot each column explicitly using a loop:
for column, colcolor in zip(2darray, colors):
pyplot.plot(2darray, column, "-", color=colcolor)
You may have to use 2darray.T, I'm not sure, and I can't check right now.
1 Comment
purpleshift
no, normally you should transpose them but the cycle pick up the first element anyway
pyplot.plot(1darray, 2darray, "-")