# Multiple Sets of Data

I would like to plot multiple sets of x and y data on the same plot with a legend. This is the code I am using right now:

y = Table[f[c1_,inc_], {c1, 0, 3, 0.1}, {inc, {0, 0.2, 0.4, 0.6}}];
x = Table[{c1 + c1 + inc}, {c1, 0, 3,  0.1}, {inc, {0, 0.2, 0.4, 0.6}}];


Each column of y corresponds to a set of y data and each column of x corresponds to a set of x data.

I would like to obtain a plot with multiple curves, ideally with a legend. Ideas?

• May you edit your question and add the definition for f and show the code you have tried. Apr 9, 2016 at 22:20
• Two things are going to be required: first, learn to use the ListPlot function. Next, learn to manipulate the lists to achieve the form that needed in the plot function. Apr 10, 2016 at 1:46

Here's a start. Since you declined to specify f[ ], I chose one.

f[x_, y_] := x^2 y^2;
y = Table[{c1 + c1 + inc, f[c1, inc]}, {c1, 0, 3, 0.1}, {inc, {0, 0.2, 0.4, 0.6}}];
ListLinePlot[Transpose[y]] • Hi! Thank you very much this helped a lot. My function is a very large mathematica output so I don't think it would have been much help to you. Do you know how I could include a legend in the plot? Apr 13, 2016 at 18:32
• How about ListLinePlot[Transpose[y], PlotLegends -> Automatic] Apr 13, 2016 at 19:35
• Hi! I get ListLinePlot::optx: Unknown option PlotLegends in <<1.>> Apr 13, 2016 at 20:47
• Maybe you are using an older version? Apr 13, 2016 at 22:39
• HI! I figured it out. I had to load the package. Your code works well. I noticed for the higher inc, that I have data points for higher x values. For example, in your graph some lines terminate earlier than others. Is there some way I could have them terminate for the same x value? Apr 14, 2016 at 14:29