问题
I have a matrix, the first column being the time, and the second column being the position of A, the third column the position of B, etc. I would like to plot the positions of A, B, ..., as functions of the time, in the same figure. Is there a more efficient way in Mathematica than making the plots column by column and then combining them by "Show"?
Also, I would like the plots have their colors automatically chosen to differ from each other; to let this automation useful, a legend is automatically generated at the same time. How to do this in Mathematica?
Thanks!
[update]: Chris' method works extremely well. But the default legend uses small dot whose colors are a bit difficult to tell; also, there seems to be only 4 colors; in my case there are ~20 y-values, making the legend effectively useless. Are there other symbols that are bigger, and with more colors (e.g., some grayscales or continuously varying colors)?
回答1:
a = {{{2001, 1, 1}, 2, 3, 4},
{{2002, 1, 1}, 3, 4, 5},
{{2003, 1, 1}, 4, 5, 6},
{{2004, 1, 1}, 5, 6, 7},
{{2005, 1, 1}, 6, 7, 8}};
DateListPlot[MapThread[Transpose[{#1, #2}] &,
{Table[First /@ a, {Length@Rest@Last@a}], Transpose[Rest /@ a]}],
Joined -> True, PlotLegends -> {"A", "B", "C"}]

来源:https://stackoverflow.com/questions/16076801/plot-using-one-column-from-a-table-as-the-x-value-other-columns-as-y-values