I was trying to plot a 2D array vs a 1D array with pyplot. I can do that with no problems and columns开发者_JAVA百科 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?
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.
精彩评论